Yii Framework Forum: Dropdown for Sorting in CListView - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Dropdown for Sorting in CListView Rate Topic: -----

#1 User is offline   Hermans 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 17-February 11

Posted 19 August 2011 - 12:58 PM

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}",

    

)); 

This post has been edited by Hermans: 19 August 2011 - 01:38 PM

0

#2 User is offline   Tahir Yasin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 29-November 11

Posted 06 August 2012 - 04:52 AM

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

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users