Yii CGridView hide filter input only

When using CGridView, the filter input fields are automatically generated by the component.

I want to select which columns will show the input field. For example: My model has 5 columns. I want CGridView to show the input filter ONLY for columns 1 and 2.

Is there a way to do it without using CSS or jQuery, just adding some code on the CGridView options?

Answers


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

should work.


If you want to remove all filters form the entire CGridView, configure 'filterPosition'=>''


Only comments and filter disappears... example:

<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'usuario-grid',
'dataProvider'=>$model->search(),
//'filter'=>'false',
'columns'=>array(
    'rut_usuario',

....


Setting 'filter'=>false, is working for me.


You can put 'filter'=> false, but this attribute will minimize the witdh of the column.. another way to disable the filtering on a specific column is to return a input with attribute 'disabled' like:

 'filter'=>'<input type="text" class="form-control" name="UsersSearch[password]" 
   disabled>',

Need Your Help

How to develop on a branch in HG?

version-control mercurial branch dvcs

I would like to do some experimental work in a hg project. So I would like to create branch, commit to it. And if the experiment works, I can merge it back to main branch.

Get list of all photo albums and thumbnails for each album

iphone ios ios5

How do I get a list of all the photo albums in iOS? I know the image picker has to have a list of them somewhere since it displays them all to the user. Once I have the photo albums, how would I go...