Dropdown for Sorting in CListView

Hello,

I tried modifying CListview to use the dropdownList on the sorting data. This may be useful for you.

please placed this code in components directory, and give YListView name.




<?php

Yii::import('zii.widgets.CListView');


class YListView extends CListView {

	

	public $sorterList;

	

	public function renderSorter(){

		echo CHtml::openTag('div',array('class'=>$this->sorterCssClass))."\n";

    	        echo $this->sorterHeader===null ? Yii::t('zii','Sort by: ') : $this->sorterHeader;

		echo CHtml::dropDownList('cbo','prompt',$this->sorterList,array('prompt'=>'Default'));

	}

	

}



and than call on your page with this code:




$this->widget('application.components.YListView', array(

	'dataProvider'=>$dataProvider,

	'sorterList'=>array('a'=>'A - Z','b'=>'x - y'),

	'itemView'=>'_view',

        'itemsTagName'=>'table',

	'template'=>"{summary}{sorter}{items}{pager}",


    


)); 



It displays drop down list but the sorter does not work. Any solution?