Filter / Search with CListView

(This is my first post, so be forgiveful!)

This is what I did. Its the EASIEST solution that I know of. I just reused the advanced search done in CGridView.

In my controller file

public function actionIndex()



                $model=new Blogs('search');

		$model->unsetAttributes();  // clear any default values



		  $this->render('index',array('dataProvider'=>$model->search(), 'model'=>$model)); //send model object for search


In my view file. (namely my index file)






	array('label'=>'Create Blogs', 'url'=>array('create')),

	array('label'=>'Search Blogs', 'url'=>array('admin')),


Yii::app()->clientScript->registerScript('search', "



	return false;


$('.search-form form').submit(function(){

	 $.fn.yiiListView.update('blogslistview', { //this section is taken from admin.php. w/only this line diff

		data: $(this).serialize()


	return false;





<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>

<div class="search-form" style="display:none">

<?php  $this->renderPartial('_search',array(


)); ?>


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



       'id'=>'blogslistview',             //must have id corresponding to js above









Nice solution, very good, and btw… Welcome to the Yii forum

NOTE: moved to proper section (Tips, Snippets and tutorials instead of General Discussion)

Hi, thanks for this solution, it works very well!

Just one slight problem though… The pager links don’t reset after each search, so for example say I am viewing page 3 of the search results, I then enter a new search term, the Clistview is refreshed with the new results but it goes to page 3 of the results. How can I make it reset to page 1 after each search?