I am trying to use CGridView with custom query, and trying to build a very simple with no sorting and stuff.
My View contains simple CGridView
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
));
And my controller passes the $dataProvider to the view
$count=Yii::app()->db->createCommand('SELECT COUNT(*) FROM ( ' . $query . ' ) as count')->queryScalar();
$dataProvider=new CSqlDataProvider($query, array(
'keyField' => false,
'totalItemCount'=>$count,
'pagination'=>array(
'pageSize'=>10,
),
));
I don't have a keyField therefore I have set it to false. Moreover, I have tried printing out data using var_dump, data is present in the variable, but still I get this undefined offset error.
You need to set the mapping for sorting.