In a Yii 1.1 application I'm displaying the data a table using the CGridView
.
$dataProvider = $model->search();
$this->widget('zii.widgets.grid.CGridView', array(
'id' => 'my-grid',
'dataProvider' => $dataProvider,
'filter' => $model,
'columns' => array(
'id',
'user.firstname',
'user.lastname',
'user.email',
'type',
'foo', // <-- on-the-fly added attribute
'bar', // <-- on-the-fly added attribute
...
),
));
Curretly all columns of model's table (id
, type
) and even the on-the-fly added attributes (foo
, bar
) get a filter input field. (The filters of the additional properties don't work.)
I want to have filters for only some of the fields, e.d. id
and tipe
. How can I enable only the filters I need / disable the filters I don't need?
Here is a solution, that looks like a workaround -- just do define the not filtered properties explicitly and set the
filter
parameter for each one tofalse
:It works, but I think, there should be a more elegant solution...