I'am trying to implement a dropdownlist inside the gridview, but it is not working.
Here's my code
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'user-grid',
'dataProvider'=>$model->roadies_search(),
'filter' =>$model,
'columns'=>array(
array(
'name'=>'hname_search',
'header'=>'Hospital Name',
'value'=>'($data->AssociatedHospitals) ? $data->AssociatedHospitals : ""',
),
array(
'type'=>'raw',
'header'=>'Users',
'id' => 'test',
'value'=>function(){
$res=Yii::app()->db->createCommand("SELECT name,id FROM med_user WHERE rank>3")->queryAll();
$html = '<select name="user" style="width:100%;">
<option selected>Select User</option>
';
foreach ($res as $key) {
$html.='<option value="'.$key['id'].'">'.$key['name'].'</option>
';
}
$html.='</select>';
return $html;
},
),
)
));
I have tried it using the following function too:
public function getUsername(){
$res=Yii::app()->db->createCommand("SELECT name,id FROM med_user WHERE rank>3")->queryAll();
return CHtml::dropDownList('usersselectlist'.$this->id,'user_id',CHtml::listData($res, 'id', 'name'));
}
I want to show all the users as a dropdown, for every row in the gridview.
EDIT
I figured out that the dropdown works fine for firefox, but the problem is with chrome. It is not showing the selected values.
Here's an example
Chrome: http://i.imgur.com/eAvBRwO.png
Firefox: http://i.imgur.com/7wBc1GX.png