/** * @inheritdoc */ protected function renderHeaderCellContent() { $name = rtrim($this->name, '[]') . '_all'; $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});"); if ($this->header !== null || !$this->multiple) { return parent::renderHeaderCellContent(); } else { return Html::tag('div', Html::checkBox($name, false, ['class' => 'select-on-check-all', 'id' => $name]) . Html::tag('label', null, ['for' => 'selection_all']), ['class' => 'checkbox']); } }
protected function renderHeaderCellContent() { $name = rtrim($this->name, '[]') . '_all'; $id = $this->grid->options['id']; $options = Json::encode(['name' => $this->name, 'multiple' => $this->multiple, 'checkAll' => $name]); $this->grid->getView()->registerJs("jQuery('#{$id}').yiiGridView('setSelectionColumn', {$options});"); if ($this->header !== null || !$this->multiple) { return parent::renderHeaderCellContent(); } else { return Checkbox::widget(['name' => $name, 'checked' => false, 'inputOptions' => ['class' => 'select-on-check-all']]); } }
/** * Renders the header cell content. * The default implementation simply renders [[header]]. * This method may be overridden to customize the rendering of the header cell. * @return string the rendering result */ protected function renderHeaderCellContent() { if ($this->gridType == 'datatable-select') { if ($this->header !== null || !$this->multiple) { return Column::renderHeaderCellContent(); } else { $name = rtrim($this->name, '[]') . '_all'; return Html::checkBox($name, false, ['class' => 'group-checkable']); } } else { return parent::renderHeaderCellContent(); } }
/** * @param mixed $model * @param mixed $key * @param int $index * * @return string * * @throws Exception */ protected function renderHeaderCellContent() { $name = rtrim($this->name, '[]') . '_all'; $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});"); if ($this->header !== null || !$this->multiple) { return parent::renderHeaderCellContent(); } else { return Checkbox::widget(['name' => $name, 'checked' => false, 'inputOptions' => ['class' => 'select-on-check-all'], 'clientOptions' => ['onChecked' => new JsExpression('function() { var $childCheckbox = $(this).closest("#' . $this->grid->options['id'] . '").find("input[name=\'' . $this->name . '\']").closest(".checkbox"); $childCheckbox.checkbox("check"); }'), 'onUnchecked' => new JsExpression('function() { var $childCheckbox = $(this).closest("#' . $this->grid->options['id'] . '").find("input[name=\'' . $this->name . '\']").closest(".checkbox"); $childCheckbox.checkbox("uncheck"); }')]]); } }
/** * Renders the header cell content. * The default implementation simply renders [[header]]. * This method may be overridden to customize the rendering of the header cell. * @return string the rendering result */ protected function renderHeaderCellContent() { $name = $this->name; if (substr_compare($name, '[]', -2, 2) === 0) { $name = substr($name, 0, -2); } if (substr_compare($name, ']', -1, 1) === 0) { $name = substr($name, 0, -1) . '_all]'; } else { $name .= '_all'; } $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});"); if ($this->header !== null || !$this->multiple) { return parent::renderHeaderCellContent(); } else { return Html::checkBox($name, false, ['class' => 'select-on-check-all']); } }
protected function renderHeaderCellContent() { $this->checkboxOptions = ArrayHelper::merge(['class' => 'sx-admin-grid-checkbox'], $this->checkboxOptions); $id = $this->grid->options['id']; $jsOptions = ['gridId' => $id]; $jsOptionsString = Json::encode($jsOptions); $this->grid->getView()->registerJs(<<<JS (function(sx, \$, _) { sx.classes.CheckboxAdmin = sx.classes.Component.extend({ _init: function() { console.log('aaaa'); }, _onDomReady: function() { \$('.select-on-check-all').on('click', function() { _.delay(function() { \$('.sx-admin-grid-checkbox').each(function() { if ( \$(this).is(":checked") ) { \$(this).closest("tr").addClass("sx-active"); } else { \$(this).closest("tr").removeClass("sx-active"); } }); }, 100); }); \$('.sx-admin-grid-checkbox').on('click', function() { if ( \$(this).is(":checked") ) { \$(this).closest("tr").addClass("sx-active"); } else { \$(this).closest("tr").removeClass("sx-active"); } }); }, _onWindowReady: function() {} }); new sx.classes.CheckboxAdmin({$jsOptionsString}); })(sx, sx.\$, sx._); JS ); return parent::renderHeaderCellContent(); }
protected function renderHeaderCellContent() { $name = rtrim($this->name, '[]') . '_all'; $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});"); if ($this->header !== null || !$this->multiple) { return parent::renderHeaderCellContent(); } else { return '<div class="input-control checkbox"><label>' . Html::checkBox($name, false, ['class' => 'select-on-check-all']) . '<span class="check"></span></label></div>'; } }