3
votes

I am trying to create a drop down using widget in my Yii web application. Here is what I am doing:

$this->widget('zii.widgets.grid.CGridView', array(
                        'id' => 'events-grid-future',
                        'filterPosition' => 'footer',
                        //'dataProvider' => $model->search('future'),
                        'dataProvider' => $model->search('future'),
                        'filter' => $model,
                        'ajaxUrl' => array('events/admin', 'search_all' => $search_all_value),
                        'itemsCssClass' => 'table table-hover table-striped table-bordered table-condensed',
                        'columns' => array(
                            array(
                                'name' => 'status',
                                'header' => 'Job Status',
                                'value' => 'ucfirst($data->status)',
                                'filter' => array('All' => 'All', 'Enquiry' => 'Enquiry', 'Contract Issued' => 'Contract Issued', 'Confirmed' => 'Confirmed', 'Hold' => 'Hold', 'Performed' => 'Performed'),
                            ),
),
)

But the drop down appears to be like this:

enter image description here

There is a null key with null value. I want to remove that. any help?

1

1 Answers

1
votes

Try adding 'empty' => '--- Select --- ' in filter:

'filter' => array('All' => 'All', 'Enquiry' => 'Enquiry', 'Contract Issued' => 'Contract Issued', 'Confirmed' => 'Confirmed', 'Hold' => 'Hold', 'Performed' => 'Performed'),array('empty'=>'--- Select --- ')