I would like to set an initial sort for CGridView… that can be changed afterwards by clicking sortable columns header…
If I set an order in the criteria of the CActiveDataProvider the data in CGridView is sorted by that column constantly… that is clicking on other column headers (that are clickable) does not resort the data… even clicking on the sorted column does not change sorting from ASC to DESC… headers are clickable and the arrow near the column header text is displayed but data are not sorted on that column.
Example:
Table pcentar has two fields (id smallint, name vchar 20)
in the controler:
$dataProvider=new CActiveDataProvider('Pcentar', array(
'criteria'=>array( 'order'=>'id' ),
'pagination'=>array( 'pageSize'=>self::PAGE_SIZE ),
));
$this->render('index',array( 'dataProvider'=>$dataProvider));
in the view:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
'name',
array(
'class'=>'CButtonColumn',
'template'=>'{update} {delete}',
),
),
));