php - How to exclude a CActiveRecord property from filtering with CGridView in Yii? -


in yii 1.1 application i'm displaying data table using 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 columns of model's table (id, type) , on-the-fly added attributes (foo, bar) filter input field. (the filters of additional properties don't work.)

i want have filters of fields, e.d. id , tipe. how can enable filters need / disable filters don't need?

here solution, looks workaround -- define not filtered properties explicitly , set filter parameter each 1 false:

... $this->widget('zii.widgets.grid.cgridview', array(     'id' => 'my-grid',     'dataprovider' => $dataprovider,     'filter' => $model,     'columns' => array(         'id',         ...         'type',         array(             'name' => 'foo',             'filter' => false,         ),         array(             'name' => 'bar',             'filter' => false,         ),         ...     ), )); 

it works, think, there should more elegant solution...


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -