How to disable sorting for a column in CGridView?

There is a flag enableSortingthat, if false, disables sorting for all columns of the grid. But how can I do this for only one specific column?

+4
source share
1 answer

try it

'sortable'=>false, 

Here is an example

$this->widget('zii.widgets.grid.CGridView', array(
    'id'=>'tasks-grid',
    'dataProvider'=>$model->search(),
    //'filter'=>$model,
    'columns'=>array(
        'id',
        array(
        'header'=>'Surname',
        'value'=> '$data->surname',
            'name'=> 'surname',
            'sortable'=>false,
            ),
        'due_date',
        'status',       
    ),
+11
source

Source: https://habr.com/ru/post/1541154/


All Articles