Searched CGridView Filter, and I did not see how to create drop down list filter in CGridView, so create this posting.
In CGridView, I want to add quick search filter on state column which will only show existed state value in the drop down list. For example, in data base we only have LS, LA, and MS, 3 states, I don’t expect the user select state from all 50 state list. See attachment screen shot.
4812
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'site-info-grid',
'dataProvider'=>$dataProvider,
'filter'=>$model,
'columns'=>array(
...
array(
'name'=>'site_state_id', //'states.state_abbv',
'filter'=>CHtml::listData($model->findAllBySql("SELECT `site_state_id`,`state_abbv` FROM `site_info` JOIN `state`
ON `state`.`state_id` = `site_info`.`site_state_id` GROUP BY `site_info`.`site_state_id` ORDER BY `state`.`state_abbv`"),
'site_state_id', 'states.state_abbv'),
'value'=>'$data->states->state_abbv',
),
...
This is very useful when the user want to pick up the value from existed data.