mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 06:11:35 +08:00
Merge branch '9074-checkboxColumn-selectedRows-fix' of https://github.com/NekitoSP/yii2 into NekitoSP-9074-checkboxColumn-selectedRows-fix
This commit is contained in:
@ -143,7 +143,7 @@
|
|||||||
var $grid = $(this);
|
var $grid = $(this);
|
||||||
var id = $(this).attr('id');
|
var id = $(this).attr('id');
|
||||||
gridData[id].selectionColumn = options.name;
|
gridData[id].selectionColumn = options.name;
|
||||||
if (!options.multiple) {
|
if (!options.multiple || !options.checkAll) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var checkAll = "#" + id + " input[name='" + options.checkAll + "']";
|
var checkAll = "#" + id + " input[name='" + options.checkAll + "']";
|
||||||
|
@ -81,6 +81,15 @@ class CheckboxColumn extends Column
|
|||||||
if (substr_compare($this->name, '[]', -2, 2)) {
|
if (substr_compare($this->name, '[]', -2, 2)) {
|
||||||
$this->name .= '[]';
|
$this->name .= '[]';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$name = $this->grid->showHeader ? $this->getHeaderCheckBoxName() : NULL;
|
||||||
|
$id = $this->grid->options['id'];
|
||||||
|
$options = json_encode([
|
||||||
|
'name' => $this->name,
|
||||||
|
'multiple' => $this->multiple,
|
||||||
|
'checkAll' => $name,
|
||||||
|
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||||
|
$this->grid->getView()->registerJs("jQuery('#$id').yiiGridView('setSelectionColumn', $options);");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,4 +142,13 @@ class CheckboxColumn extends Column
|
|||||||
|
|
||||||
return Html::checkbox($this->name, !empty($options['checked']), $options);
|
return Html::checkbox($this->name, !empty($options['checked']), $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns header checkbox name
|
||||||
|
* @return string header checkbox name
|
||||||
|
*/
|
||||||
|
private function getHeaderCheckBoxName()
|
||||||
|
{
|
||||||
|
return rtrim($this->name, '[]') . '_all';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,6 +272,11 @@ class GridView extends BaseListView
|
|||||||
$this->filterRowOptions['id'] = $this->options['id'] . '-filters';
|
$this->filterRowOptions['id'] = $this->options['id'] . '-filters';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$id = $this->options['id'];
|
||||||
|
$options = Json::htmlEncode($this->getClientOptions());
|
||||||
|
$view = $this->getView();
|
||||||
|
$view->registerJs("jQuery('#$id').yiiGridView($options);");
|
||||||
|
|
||||||
$this->initColumns();
|
$this->initColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,11 +285,9 @@ class GridView extends BaseListView
|
|||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$id = $this->options['id'];
|
|
||||||
$options = Json::htmlEncode($this->getClientOptions());
|
|
||||||
$view = $this->getView();
|
$view = $this->getView();
|
||||||
GridViewAsset::register($view);
|
GridViewAsset::register($view);
|
||||||
$view->registerJs("jQuery('#$id').yiiGridView($options);");
|
|
||||||
parent::run();
|
parent::run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user