Filter data in CListView and CGridView using AJAX. How?

Hello. I create search widget which using CHtml::ajaxSubmitButton send data in Filter action

public function actionFilter()


            $session=new CHttpSession;




For test i save filter data in session. Then i add this data to add SearchCondition.

My List action:

public function actionList()




            $session=new CHttpSession;


            $criteria=new CDbCriteria();


            $dataProvider=new CActiveDataProvider('estate', array(




            $this->render('estate', array('dataProvider'=>$dataProvider,));


Estate view:


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









How reload CListView items using AJAX after add SearchCondition? Thank you in advance for your help.

Hi, did you figure this out? Thanks!

yea, filtering CListView would be very nice. What i like about CListView vs. CGridView is that listview has independent view files for each row, while gridview echos all the data out. I need to make some pretty custom rows and filter them, and looking like a plain jane table like gridview produces won’t do. So I’m about to try to modify the html gridview spits out (e.g. so instead of <td> elements like divs are used). But my guess is that all the sorting/filtering/paging js all breaks.

So Basically CListView with filtering would give you the most important stuff from gridview, but with cleaner html _view files for each row/item. Would love to see ListView extended to do this right.

You can achive it by creating your own ajax pager. read this post for know how.

Then you can configure your CListView for use the pager:

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


    'itemView'=>'_post',   // refers to the partial view named '_post'




i’d say the easiest way is to call the js update-function of the listview after your ajax request is completed.

By defining your ajaxSubmitButton something like this:

ajaxSubmitButton('Lets go', 'REQUEST_URL', array('success'=>'$.fn.yiiListView.update("LIST_ID");')); // Replace LIST_ID with the ID of the CListView you want to update

After the ajax call of your ajaxSubmitButton was successful (and the search data was stored inside the session) it triggers the build-in js function that updates the listview.


Anybody developed an elegant solution for this yet?

Ideally what I’m after is a filter row at the top that works just like CGridView but instead of table rows we have CListView instead.

Anyone else agree that CListView should be enhanced to include the filtering functionality, similar to CGridView? Furthermore, I think there should be an option to put the sorting filters into a dropdown.

we can update CListView similar to CGridView. In a form we have input field. When form submitted, ajax call occured. In our list action we can get value of our field via $_GET. and then apply necessary conditions to our criteria. Sorry for my bad english )



       $.fn.yiiListView.update('list', {

             data: $(this).serialize()


         return false;


following link will help you to filter data in CListView using AJAX.