任何人都可以告诉如何通过yii cgridview下拉列表列中的ajax传递id?

时间:2015-09-04 11:29:22

标签: php gridview yii

这是我的代码:

array(
    'name' => 'bug_status',
    'type' => 'raw',
    'value' => "CHtml::dropDownList('status', '', array('1' => 'Open' , '2' => 'Fixed' , '3' => 'Closed' , '4' => 'Re-Open' , '5' => 'Clarification'),
    array(
        'ajax' => array(
        'type'=>'GET', 
        'data'=>array('status' => 'js:this.value'), 
        'dataType' => 'text',
        'url'=> Yii::app()->createUrl('bugDetails/statuslevel',array('id' => 1)),    
                'success' => 'function(data){alert(data);}',
    )))",
),

2 个答案:

答案 0 :(得分:0)

您可以添加第四个参数htmloptions

echo  CHtml::dropDownList($model, 'field_name',
      $optionsArray,
      array('id'=>'add_id_to_your_drop_down'));

答案 1 :(得分:0)

array(
    'name' => 'bug_status',
    'type' => 'raw',
    'value' => function($data) {
         // you can use $data->yourStatusId 
         // default - Closed(3).
         return CHtml::dropDownList('status', 3/*active id*/, array('1' => 'Open' , '2' => 'Fixed' , '3' => 'Closed' , '4' => 'Re-Open' , '5' => 'Clarification'));
    }
    //..
),