Custom Filtering For Cgridview

Hi,

I am using CGridView to display results from postgres function. The CGridView is working fine. Now I want to use a different function in the model for filtering the CGridView.

The current code for CGridView is like

$this->widget(‘zii.widgets.grid.CGridView’, array(

'id'=>'purchase-grid',


'itemsCssClass'=>'table table-bordered table-condensed table-hover table-striped dataTable',


'filter'=>$model,


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


    ..............

The $model->search() function accepts an id which is used to select rows from the table. I am using CSqlDataProvider to run custom query in the $model->search() and returns the dataprovider. If I use the above code it will display filter textbox for all the fields in the CGridView. But the search function is using an id that is not displayed in the CGridView. So filtering is not working. So I want to use a new function for filtering which will accept the field for filtering. I tried with the code below

$this->widget(‘zii.widgets.grid.CGridView’, array(

'id'=>'purchase-grid',


'itemsCssClass'=>'table table-bordered table-condensed table-hover table-striped dataTable',


'filter'=>$model->filter_search(),


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


    ..............

But it shows error. Please help.

Thanks in advance.

What errors did you get? What do you do in filter_search() method? Could you please post them here (so that we would be able to understand your problem better)?

Normally, we applied customer filter for each row individually. There are many discussions about that. Search key word "cgridview filter".

See some examples below:

http://www.yiiframework.com/forum/index.php/topic/7046-grid-view-and-filter/page__p__237065__hl__filter__fromsearch__1#entry237065

http://www.yiiframework.com/forum/index.php/topic/48191-drop-down-list-as-filter-in-cgridview/page__p__225328__hl__filter__fromsearch__1#entry225328

http://www.yiiframework.com/forum/index.php/topic/36157-cgridview-filter-data/page__p__222301__hl__filter__fromsearch__1#entry222301