4

There is the enableSorting flag, that, if equals false, disable sorting for all grid columns. But how can I do this for just one specific column?

Tasso Evangelista
  • 1,612
  • 1
  • 16
  • 23

1 Answers1

11

try this

'sortable'=>false, 

Here is 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',       
    ),
ramamoorthy_villi
  • 1,939
  • 1
  • 17
  • 40
  • Thanks fellow, but I'm trying exactly the oposite: disable sorting in one column. I achieved this by using `'sortable' => false`. Just correct your answer and I'll accept it. – Tasso Evangelista May 19 '14 at 18:39
  • what if we want to make all column sort able with one liner code? – Jigar7521 Jan 08 '18 at 08:53