Dropdown for Sorting in CListView


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.



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(


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






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