Krajee

Batch Loading

Thankful to Krajee! BUY A COFFEEor to get more out of us.
Scenario for batch loading of models. You can set the batchSize property to fetch models in batches of this size from the dataProvider. This will improve the memory usage by not loading all the models into memory. The exported output will still be a single file containing all data, but it will be rendered with models selected in a batch mode to generate output rows. Each batch will read batchSize number of models at a time, and once processed the next batch of models will be retrieved from the dataProvider.

Tip

Not seeing the updated content on this page! Hard refresh your browser to clean cache for this page (e.g. SHIFT-F5 on Windows Chrome)


Showing 1-5 of 20 items.
#IDNameAuthorColorPublish DateStatusBuy Amount ($)Sell Amount ($)Actions
11008BelovedToni Morrisongreen2000-10-01Inactive130.00154.99
21013Brave New WorldAldous Huxleyblue2011-08-21Active115.00175.50
31006Catch-22Joseph Hellercyan2011-08-21Active85.00105.50
41016Gone with the Wind Margaret Mitchellbrown2011-08-21Active123.00185.50
51015Invisible ManRalph Ellisoncyan2011-08-21Active105.00165.50
use kartik\export\ExportMenu;
use kartik\grid\GridView;
echo ExportMenu::widget([
    'dataProvider' => $dataProvider,
    'columns' => $gridColumns,
    'batchSize' => 10,
    'target' => '_blank',
    //'folder' => '@webroot/tmp', // this is default save folder on server
]) . "<hr>\n".
GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => $gridColumns,
]);
$gridColumns = [
    ['class' => 'kartik\grid\SerialColumn'],
    'id',
    'name',
    [
        'attribute'=>'author_id',
        'label'=>'Author',
        'vAlign'=>'middle',
        'width'=>'190px',
        'value'=>function ($model, $key, $index, $widget) { 
            return Html::a($model->author->name, '#', []);
        },
        'format'=>'raw'
    ],
    'color',
    'publish_date',
    'status',
    ['attribute'=>'buy_amount','format'=>['decimal',2], 'hAlign'=>'right', 'width'=>'110px'],
    ['attribute'=>'sell_amount','format'=>['decimal',2], 'hAlign'=>'right', 'width'=>'110px'],
    ['class' => 'kartik\grid\ActionColumn', 'urlCreator'=>function(){return '#';}]
];

Note

You can now visit the Krajee Webtips Q & A forum for searching OR asking questions OR helping programmers with answers on these extensions and plugins. For asking a question click here. Select the appropriate question category (i.e. Krajee Plugins) and choose this current page plugin in the question related to field.

The comments and discussion section below are intended for generic discussions or feedback for this plugin. Developers may not be able to search or lookup here specific questions or tips on usage for this plugin.

 
visitors to Krajee Yii2 Demos since 22-May-2017