By default, Grid creates filter control in a form of text box. For one of my columns I want to replace that with
DropDownList selector. How can I do this?
Thanks.
By default, Grid creates filter control in a form of text box. For one of my columns I want to replace that with
DropDownList selector. How can I do this?
Thanks.
array(
'name'=>'attribute',
'value'=>'$data->attribute',
'filter'=>array(<data options>),
),
For example
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'properties-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'columns'=>array(
'id',
'title',
array(
'name'=>'state_id',
'value'=>'$data->state->name',
'filter'=> CHtml::listData(States::model()->findAll(), 'id', 'name'),
),
'year_build',
'city',
array(
'name'=>'featured',
'value'=> $model->featured,
'filter'=>array(0=>"No", 1=>"Yes"),
),
array(
'name'=>'type_id',
'value'=>'$data->type->name',
'filter'=> CHtml::listData(Types::model()->findAll(), 'id', 'name'),
),
array(
'name'=>'listing_type_id',
'value'=> $model->listing_type_id,
'filter'=> CHtml::listData(ListingTypes::model()->findAll(), 'id', 'name'),
),
'price',
'user.username',
array(
'class'=>'CButtonColumn',
),
),
)); ?>
Thank you omko. This is the answer I was looking for.
Cheers.
filters are not working please help
oh man, sorry to hear that!
Hi,
i have this problem:
an field has this values: (0,1,2,3,4,5)
It’s possible create an filter that show
all records > 0
?
For to show all records > 0:
'filter'=>array('<1'=>'empty','>0'=>'full'),
but how can I add this item to the following filter?
'filter'=> CHtml::listData(States::model()->findAll(), 'id', 'name'),