Thursday 24 April 2014

Replace textfield with dropdown yii grid

In Yii CGridview you can replace default text-field with drop-down to filter records. You just need to add following line in your columns array. Ex. I have added "Category" column along with drop-down filter.

     'category'=>array(
        'name' => 'category',
        'value' => '$data->category',
        'filter'=> CHtml::listData(CustomerSpendings::model()->findAll(array('order'=>'category')), 'category', 'category')
    ),