我做了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'=>中将参数传递给actionupdate $这 - > createUrl( 'StudentTable /更新'),
答案 0 :(得分: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();
}
我将更新操作放在主控制器中,然后以这种方式重复使用我的所有网格。