Cgridview Filter Not Working

Hello everyone! Im having a bot of a problem here…

I have a CGridView widget, complete with the required models and everything. I configured the models to filter the data properly and everything works. However, I noticed something.

When I place a data in the Filtering text box, the data is filtered properly. When I remove the data to reset the table, it also works properly. However, when I try to filter the data again after going to the next page, it just doesn’t work. No errors, no filtering, nothing.

I also noticed that the pagination changes its url after resetting the table from this one:

www.site.com/deal/default/index/DealModel_page/2

to this one:

www.site.com//deal/default/index/DealModel[companyId]//DealModel[id]//DealModel[referenceCode]//

DealModel%5BdealName%5D//DealModel%5Bcity%5D//DealModel%5Bstartfilter%5D//DealModel%5Bendfilter%5D//

DealModel%5Bstatus%5D//DealModel_page/2/ajax/dealList-grid"

I searched the net for answers but to no avail. Can I kindly ask for assistance? Thank you!

Turns out I just have to add an ajaxurl property to my CGridVIew…

‘ajaxUrl’=>Yii::app()->createUrl( ‘deal/default/index’ ),

After that, everything will be ok. Hope this post will help somebody in the future… :slight_smile:

The issue was caused by you refresh the whole page instead of using Ajax to refresh part of page. In this case, we have to think about to use:




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

	'id'=>'user-grid',

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

	'ajaxUpdate' => FALSE,  //this not call ajax update, will refresh whole page.

...