Difference between #1 and #2 of Filter / Search with CListView

unchanged
Title
Filter / Search with CListView
unchanged
Category
How-tos
unchanged
Tags
filter, CListView, CGridView, search
changed
Content
(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. 

<b>In my controller file</b>



~~~
[php]
public function actionIndex()
{
    $model=new	{
            
                $model=new Blogs('search');
    $model->unsetAttributes();
		$model->unsetAttributes();  // clear any default values
    if(isset($_GET['Blogs']))
        $model->attributes=$_GET['Blogs'];
		if(isset($_GET['Blogs']))
			$model->attributes=$_GET['Blogs'];

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



<b>In my view file</b> (namely my index file)


~~~
[php]
<?php
$this->breadcrumbs=array(
    'Blogs',	'Blogs',
);

$this->menu=array(
    array('label'=>'Create	array('label'=>'Create
Blogs', 'url'=>array('create')),
    array('label'=>'Search
	array('label'=>'Search Blogs', 'url'=>array('admin')),
);
Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    return	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
    $.fn.yiiListView.update('blogslistview',	
$.fn.yiiListView.update('blogslistview', { 
        //this//this entire js section is taken from admin.php.
w/only this line diff
        data:
		data: $(this).serialize()
    });
    return
	});
	return false;
});
");
?>

<h1>Blogs</h1>

<?php echo CHtml::link('Advanced
Search','#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php  $this->renderPartial('_search',array(
    'model'=>$model,	'model'=>$model,
)); ?>
</div>

<?php $this->widget('zii.widgets.CListView', array(
    'dataProvider'=>$dataProvider,
    'itemView'=>'_view',
    'id'=>'blogslistview',       //
must	'dataProvider'=>$dataProvider,
	'itemView'=>'_view',
       'id'=>'blogslistview',             //must have id corresponding
to js above
    'sortableAttributes'=>array(
       'sortableAttributes'=>array(
        'id',
        'startdate',
        'enddate',
        'user_id',   'enddate',
           'user_id',
    ),
)); 
?>
~~~