Answer the question
In order to leave comments, you need to log in
Yii - how to filter and sort custom columns in cgridview?
Good afternoon!
I will give a hypothetical example. In CGridView I create a custom column:
array(
'header'=>'Заголовок',
'type'=>'raw',
'value'=>'$data->id + 90',
)
Answer the question
In order to leave comments, you need to log in
www.yiiframework.com/doc/api/1.1/CDataColumn#sorta...
The property sortable determines whether the grid view can be sorted according to this column. Note that the name should always be set if the column needs to be sortable. The name value will be used by CSort to render a clickable link in the header cell to trigger the sorting.
In a nutshell: you need to specify the model attribute in the name and set the CSort accordingly when forming the dataProvider so that the column is rendered in the table as sortable. But if you calculate the value at the presentation level, as in the example, then there is a chance to get the wrong order.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question