问题描述
我做了 x-editable 站点中提到的所有事情(我正在使用 EditableColumn,这是链接 http://x-editable.demopage.ru/?r=site/widgets#EditableField)
i did every thing as mention in the x-editable site ( i'm using EditableColumn, here's the link http://x-editable.demopage.ru/?r=site/widgets#EditableField)
我无法更新我的数据库,谁能告诉我如何通过传递主键来调用 actionupdate
i can't update my db, can any one tell me how to call actionupdate with passing the primary key
$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,
in actionupdate we need to pass edited value id please tell me,how to pass parameter to actionupdate in 'url' => $this->createUrl('StudentTable/Update'),
推荐答案
我是这样做的:
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();
}
我将更新操作放在主控制器中,然后它可以通过这种方式在我的所有网格上重复使用.
I placed my update action in the main controller and then it was reusable on all my grids this way.
这篇关于如何使用 x-editable EditableColumn 更新数据库值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!