Hello, I am using CArrayDataProvider as the data provider for a CGridView, and everything works fine, except the sorting.
The "sorting links" are already in the column headers, but when I click any of them, the table gets empty.
Basically, this is what I’m doing:
In the model:
$command = Yii::app()->db->createCommand();
$command->select('*');
$command->from('example');
$rawData = $command->queryAll();
$dataProvider=new CArrayDataProvider($rawData, array(
'sort'=>array(
'attributes'=>array(
'field1', 'field2'
),
),
'pagination'=>array(
'pageSize'=>20,
),
));
In the view:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
array(
'name'=>'field1',
'header'=>' My Field 1',
),
array(
'name'=>'field2',
'header'=>' My Field 2',
),
),
));
Am I missing something? I will appreciate any ideas to make the sorting work.
Thanks in advance!