3

我做了 x-editable 网站中提到的所有事情(我正在使用 EditableColumn,这是链接http://x-editable.demopage.ru/?r=site/widgets#EditableField

我无法更新我的数据库,谁能告诉我如何通过传递主键来调用 actionupdate

$this->widget('bootstrap.widgets.TbGridView', array(
'id' => 'user-grid',
'itemsCssClass' => 'table table-striped table-bordered table-condensed',
'dataProvider' => $model->search(),
'columns'=>array(
     'student_id',
    array(
       'class' => 'editable.EditableColumn',
        'id' =>'student_name',
       'name' => 'student_name',
       'headerHtmlOptions' => array('style' => 'width: 110px'),
       'editable' => array(    //editable section
              'apply'      => '$data->student_id', //can't edit deleted users
              'url'        => $this->createUrl('StudentTable/Update'),
              'placement'  => 'left',
          )               
    ),));

在 actionupdate 中我们需要传递编辑的值 id 请告诉我,如何在 'url' => $this->createUrl('StudentTable/Update') 中将参数传递给 actionupdate,

4

1 回答 1

2

我是这样做的:

array(
            'class' => 'editable.EditableColumn',
            'name' => 'field',
            'editable' => array(
                'url'        => $this->createUrl('updateEditable', array('model'=>'modelName', 'field'=>'field1')),
                'placement'  => 'top',
                'inputclass' => 'span3',
            )
        ),

还有我的更新动作

public function actionUpdateEditable() {
    Yii::import('bootstrap.widgets.TbEditableSaver');
    $es = new TbEditableSaver($_GET['model']);  // 'modelName' is classname of model to be updated
    $es->update();
}

我将更新操作放在主控制器中,然后以这种方式在我的所有网格上重复使用。

于 2013-06-03T21:33:41.617 回答