Krajee

Large Files Linking

Thankful to Krajee! BUY A COFFEEor to get more out of us.
An example showing how you can download larger export files without streaming to browser. You need to set stream property to false. This way the exported data will be directly written to a file instead of streaming to buffer. The exported file will be then displayed as a web accessible link for download. You may see some improvement by avoiding memory issues due to output buffering, and the file is saved directly to a web server folder. You can provide the folder and linkPath properties to set the folder for saving and the web accessible link location for the saved file respectively. The extension will automatically show a link to the saved file based on above settings. You can set the afterSaveView file to point to your own view that displays the generated file link. Note: The target property will automatically be overridden to ExportMenu::TARGET_SELF or _self when this is set.

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 11-15 of 20 items.
#IDNameAuthorColorPublish DateStatusBuy Amount ($)Sell Amount ($)Actions
111011The Lord of the RingsJ. R. R. Tolkienpurple2007-09-08Active109.00158.50
121012One Hundred Years of SolitudeGabriel García Márquezyellow2004-05-09Active165.00195.50
131013Brave New WorldAldous Huxleyblue2011-08-21Active115.00175.50
141014To the LighthouseVirginia Woolfpink2004-05-09Active105.00145.50
151015Invisible ManRalph Ellisoncyan2011-08-21Active105.00165.50
use kartik\export\ExportMenu;
use kartik\grid\GridView;
echo ExportMenu::widget([
    'dataProvider' => $dataProvider,
    'columns' => $gridColumns,
    'stream' => false, // this will automatically save file to a folder on web server
    //'afterSaveView' => '_view', // this view file can be overwritten with your own that displays the generated file link
    //'folder' => '@webroot/runtime/export', // this is default save folder on server
    //'linkPath' => '/runtime/export', // the web accessible location to the above folder
]) . "<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