Is there any way to hide/show the gridview column depending on whether the search form field is blank/not?
Any suggestion or tips will be highly appreciated.
Thanks in advance.
Is there any way to hide/show the gridview column depending on whether the search form field is blank/not?
Any suggestion or tips will be highly appreciated.
Thanks in advance.
If you use the standard actionAdmin (generated by gii), the submitted model attributes are populated with the search values.
So you can check the attributes of the model to set the visibility property of a column:
$this->widget('zii.widgets.grid.CGridView',array(
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
array(
'name' => 'attribute1',
'visible' => !empty($model->attribute1),
...
),
...