0

I would like to display two Kartik's Gridviews (with editable columns) within one form.

The problem is, if i would like to edit a value in the second gridview, the editable popup opens for the coresponding row in the first gridview.

Looking into the html, the id of the editables are the same for the between the two gridviews.

Picture of the two gridviews; editable in second grid was clicked.

The definition of the two gridviews in the view:

echo GridView::widget([
    'id' => 'your_gridview_one',
    'dataProvider'=>$dataProvider,
    'columns'=>$gridColumns,
    //'filterModel' => $searchModel,
    'showHeader' => true,
]);

 echo GridView::widget([
    'id' => 'your_gridview_two',
    'dataProvider'=>$secondDataProvider,
    'columns'=>$gridColumns,
    //'filterModel' => $searchModel,
    'showHeader' => true,
]);

How can i change the ids of the editables?

Luc
  • 365
  • 4
  • 22
  • Looks like that editable is picking up a CSS wrong selector. I would suggest checking `contentOptions` property of `yii/grid/DataColumn` http://www.yiiframework.com/doc-2.0/yii-grid-datacolumn.html – antoniom Feb 23 '17 at 21:41

1 Answers1

2

You can not use the same $gridColumns in both GridView. You have to give to the form (the editable popup) and the input field in it a unique HTML id. Something similar:

[
    'class' => 'kartik\grid\EditableColumn',
    'attribute' => 'name', 
    'editableOptions' => function ($model, $key, $index) {
        return [
            'formOptions' => [
                'id' => 'gv1_' . $model->id . '_form_name',
                'action' => \yii\helpers\Url::to(['recipe-lang/index'])
            ],
            'options' => [
                'id' => 'gv1_' . $model->id . '_name',
            ],
        ];
    },
],
Tibor Nagy
  • 1,185
  • 1
  • 15
  • 28
  • Thank you for the hint. Changing my code like you pointed out, did change the popups; every popup opens for its corresponding editable field. good for now, thanks. Anyhow, for the second gridview the popup of an editable opens but doesn't show anything; its empty. From the rendered html the following tag is missing: – Luc Feb 24 '17 at 06:18