I use a CDataProvider and a CGridView to display a listing of a model’s records. In CDataProvider, I have this code:
$dataProvider = new CActiveDataProvider('Receipt', array(
'criteria'=>array('with'=>array('category', 'theBuyer', 'persons')),
'sort'=>array('defaultOrder'=>array('date'=>TRUE))));
Receipt belongs to many categories (category relation). The grid is displayed nicely:
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array('id', 'afm', 'date', 'price', 'reason',
array('name'=>'Category name', 'value'=>'$data->category->name', 'sortable'=>TRUE),
),
'enableSorting'=>TRUE,
));
but all columns are sortable except from the category name column (from the category relation). How do I make it sortable?