Hi,
I’ve read a little bit about CGridView sorting on this forum, as good as about enableSort, IDataProvider.sort etc. But the thing is that I wrote my fourth grid view in current project by copying and modifying code of one of last three and all three have sorting working like a charm (like previously) and the fourth one hasn’t got it (header titles not being links).
My grid view definition seems to be correct:
$this->widget('zii.widgets.grid.CGridView', array
(
'summaryText'=>'',
'id'=>'users-grid',
'ajaxUpdate'=>false,
'selectableRows'=>1,
'emptyText'=>$emptyText,
'dataProvider'=>$model->search(),
'selectionChanged'=>'function(id){onGridViewSelectionChange($.fn.yiiGridView.getSelection(id))}',
'columns'=>array
(
...
)
)
As good as my search function defined in model and used above:
public function search()
{
$cfg = new Settings('listy');
$criteria = new CDbCriteria;
$criteria->condition = 'del = 0';
return new CActiveDataProvider(get_class($this), array
(
'criteria'=>$criteria,
'sort'=>array('defaultOrder'=>array('LOGN'=>false)),
'pagination'=>array('pageSize'=>$cfg->getValue('user.rec_no'))
));
}
So, I have some sort of problems figuring out what did I mess up during code copying/modification, that sorting of this grid view has disappeared? Can any one help or advice here?
BTW: Pagination works fine.
Being in the same topic, I would also like to ask about MVC. Digging through forum, I found out that many posters has search function or data provider, used in CGridView, declared in either controller or even view. Shouldn’t it be in model according to MVC, as I did? I think this is an integral part of model.