Tuesday, 23 September 2014

Dropdown Filter in CGridView

$month_list=array('1'=>'JAN','2'=>'FEB');
$this->widget('zii.widgets.grid.CGridView', array(
 'id'=>'form-grid',
 'dataProvider'=>$model->search(),
 'filter'=>$model,
 'columns'=>array(
        array(
            'name'=>'festivals.festival_name',
            'filter' => CHtml::activeTextField($model, 'festival_name'),
            ),      
  'day',
        array(
            'name'=>'month',
             'value'=>function($data,$row) use ($month_list){
                            return $month_list[$data->month];
                        },
             'filter'=>CHtml::activeDropDownList($model,'month',$month_list,array('empty'=>'Select Month')),
            ),
...........

No comments:

Post a Comment