Sorting without filtering on a column in cgridview

Hello,

Is it possible to sort the column in cgridview without enabling the filter text box?

yes




<?php $this->widget('zii.widgets.grid.CGridView', array(

        'id'=>'genre-grid',

        'dataProvider'=>$model->search(),

        /* 'filter'=>$model, */

        'columns'=>array(

                ...

        ),

)); ?>



http://www.yiiframework.com/doc/api/1.1/CGridView/#filter-detail

Hi! You could filter only fields you need and keep sorting at the same time with ‘filter’=>false like this:


<?php $this->widget('zii.widgets.grid.CGridView', array(

        'id'=>'grid_id',

        'dataProvider'=>$model->search(),

        'filter'=>$model,

        'columns'=>array(

 		array('name'=>'field_0','value'=>'$data->field_0','filter'=>false),

		array('name'=>'field_1','value'=>'$data->field_1'),

               ...

        ),

)); ?>

Happy to make happy :rolleyes: .