Hi,
I am trying to export the result from the grid of yii. But as the data to the grid is provided by a array, i am not able to export the grid result.
Following code i am calling in my controller
$productData = $this->outofstockProduct();
$dataProvider2 = new CArrayDataProvider(
$productData, array(
'sort'=>array(
'attributes'=>array('id','*'),
//'defaultOrder'=>array('entity_id' => false),
),
'pagination'=>array(
'pageSize'=>10,
),
));
if ($this->isExportRequest()) { //<==== [[ADD THIS BLOCK BEFORE RENDER]]
//set_time_limit(0);
$this->exportCSV($dataProvider2, array('id',
'name',
'category',
'code'));
}
$this->render('index',array(
'dataProvider'=>$dataProvider2,
));
// following is the way i am exporting the result in view pages
<?php $gridWidgetProduct = $this->widget('zii.widgets.grid.CGridView',array(
'id'=>'product-grid',
'dataProvider' => $dataProvider,
'columns'=>array(
'id',
'name',
'category',
'code',
)
));
?>
<?php
$this->renderExportGridButton($gridWidgetProduct,'Export Grid Results',array('class'=>'btn btn-info pull-right'));
?>
Can any please help to rectify my mistake