How can update db values using x-editable Editable

2019-02-24 21:55发布

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)

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',
          )               
    ),));

in actionupdate we need to pass edited value id please tell me,how to pass parameter to actionupdate in 'url' => $this->createUrl('StudentTable/Update'),

标签: yii
1条回答
叛逆
2楼-- · 2019-02-24 22:18

I did it like this:

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

And my update action

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.

查看更多
登录 后发表回答