Filter in CGridView columns

Hi! I have a problem using filter in CGridView columns




$this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'delivery-grid',

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

	'filter'=>$model,

	'columns'=>array(

            'id',

            'name',

	    array(

		'name'=>'letter_id',

		'value'=>'$data->letter->name',

		'filter'=>CHtml::listData(Letter::model()->findAll(), 'id','name'),

	     ),

	     array(

		'name'=>'letter.lang_id',

		'value'=>'$data->letter->lang->name',

		'filter'=>CHtml::listData(Lang::model()->findAll(), 'id','name'),

	     ),

            'begin',

            'end',

            array(

                'name' => 'status',

                'value' => '$data->status ? \'yes\' : \'no\'',

                'filter' => array('0' => 'no', '1' => 'yes'),

            ),

            array(

                'class'=>'CButtonColumn',

            ),

	),

));



CHtml::listData(Lang::model()->findAll(), ‘id’,‘name’) generates the array I want, but there is no dropdown list of available languages, although in the column before everything is allright.

Can anybody explain why ?

Beforehand thanks!

Hi Evrimedont, welcome to the forum.

As MrSoundless states in an other post,

CGridView filters hasMany relationship

So you have to introduce a virtual attribute for letter.lang_id.

See the link that he has posted for details.