Sorting CListView with dropdown

So I have a CListView, that I can sort using the attributes I’ve set in sortableAttributes, this is fine when it’s just ASC and DESC sorting. But I also want to sort the CListView by a category. In my model I have a category, ranging from 0-8. I’ve made a dropdown select that shows the categories.

What I would like to do is update my CListView when an option in the dropdown is selected, I could write my own jQuery code for this, but I’m guessing there is some smart yii way of doing this.

So updating the CListView like if I set /index?Video[category]=4 just by using AJAX instead, like my sortableAttributes does.

Thanks


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

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

    'sortableAttributes'=>array('views','create_time','release_time'),

    'id'=>'#videos',

    'itemView'=>$view,

    'pager'=>array('cssFile'=>'/css/pager.css'),

)); ?>

For future reference, this is how I ended up doing it.


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

$('#category').change(function(){

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

		data: $(this).serialize()

	});

	return false;

});

");

The important part is the id in the htmlOptions of the dropDownList, as you cannot use "Video[category]" as the id for the $.fn.yiiListView.update function. But it is needed as the name of the select, to be able to use the already existing search ability.


<?php echo CHtml::dropDownList(

	'Video[category]',

	0,

	Lookup::items('VideoCategory'),

	array('id' => 'category')

); ?>