Dropdownlist Filter In Cgridview

Code for CGridView:

<?php $this->widget(‘zii.widgets.grid.CGridView’, array(
























Relations between the two tables:

public function relations()


	// NOTE: you may need to adjust the relation name and the related

	// class name for the relations automatically generated below.

	return array(

		'tbHints' =&gt; array(self::HAS_MANY, 'TbHints', 'puzzle_id'),

		'group' =&gt; array(self::BELONGS_TO, 'PuzzleGroup', 'group_id'),

		'category' =&gt; array(self::BELONGS_TO, 'PuzzleCategory', 'category_id'),



Code for search function:

public function search()


	// Warning: Please modify the following code to remove attributes that

	// should not be searched.

	&#036;criteria=new CDbCriteria;







	return new CActiveDataProvider(&#036;this, array(




For the above code can anyone please let me know how to create CGridView for Puzzle with dropdownlist filters containind puzzlegroup name from PuzzleGroup which is related to Puzzle with group_id.

Also i want to display PuzzleGroup name instead of id in the CGridView.

Dear JaswalKiranAvtar

Please try to create a column like this.





'value'=>'$data->group->name', //single quotes



The following wiki is very useful one.

Searching and sorting by related model in CGridView