kartik-v / yii2-grid

Enhanced GridView with various utilities for Yii Framework 2.0
http://demos.krajee.com/grid
Other
556 stars 303 forks source link

EditableColumn does not use $grid->options['id'] . '-pjax' for its pjaxContainerId #896

Closed adamwinn closed 5 years ago

adamwinn commented 5 years ago

Prerequisites

In EditableColumn.php, it says

if ($this->grid->pjax && empty($this->_editableOptions['pjaxContainerId'])) {
    $this->_editableOptions['pjaxContainerId'] = $this->grid->pjaxSettings['options']['id'];
}

but the docs say:

The pjax container identifier is read via pjaxSettings['options']['id'] . You could override and manually set pjaxSettings['options']['id'] if you need your own pjax container identifier. If not set this defaults to: $grid->options['id'] . '-pjax'

So if you dont manually set pjaxSettings['options']['id'] and rely on the default of $grid->options['id'] . '-pjax', your pjaxContainerId will not be set automatically like it's doing for $this->grid->pjaxSettings['options']['id']

I think there should be a check for this should be included. Something like:

if ($this->grid->pjax && empty($this->_editableOptions['pjaxContainerId'])) {
    if(empty($this->grid->pjaxSettings['options']['id'])) {
           $this->_editableOptions['pjaxContainerId'] = $grid->options['id'] . '-pjax';
        }        
        else {      
           $this->_editableOptions['pjaxContainerId'] = $this->grid->pjaxSettings['options']['id']; 
       }
}

Then the people that rely in the default of $grid->options['id'] . '-pjax'; will automatically get their pjaxContainerId set just like they would if they specified $this->grid->pjaxSettings['options']['id']