The default implementation simply renders [[header]].
This method may be overridden to customize the rendering of the header cell.
protected renderHeaderCellContent ( ) : string | ||
return | string | the rendering result |
/** * 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 = 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 Html::checkBox($name, false, ['class' => 'select-on-check-all']); } }
protected function renderHeaderCellContent() { if ($this->header !== null || $this->label === null && $this->attribute === null) { return parent::renderHeaderCellContent(); } $provider = $this->grid->dataProvider; if ($this->label === null) { if ($provider instanceof ActiveDataProvider && $provider->query instanceof ActiveQuery) { /** @var Model $model */ $model = new $provider->query->modelClass(); $label = $model->getAttributeLabel($this->attribute); } else { $models = $provider->getModels(); if (($model = reset($models)) instanceof Model) { /** @var Model $model */ $label = $model->getAttributeLabel($this->attribute); } else { $label = Inflector::camel2words($this->attribute); } } } else { $label = $this->label; } if ($this->attribute !== null && $this->enableSorting && ($sort = $provider->getSort()) !== false && $sort->hasAttribute($this->attribute)) { return $sort->link($this->attribute, array_merge($this->sortLinkOptions, ['label' => Html::encode($label)])); } else { return Html::encode($label); } }
/** * 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(); } }
/** * @inheritdoc */ protected function renderHeaderCellContent() { if ($this->header !== null || !$this->showClear) { return parent::renderHeaderCellContent(); } else { $label = ArrayHelper::remove($this->clearOptions, 'label', '×'); Html::addCssClass($this->clearOptions, 'kv-clear-radio'); if (empty($this->clearOptions['title'])) { $this->clearOptions['title'] = Yii::t('kvgrid', 'Clear selection'); } $this->_view->registerJs("kvClearRadio({$this->_clientVars});"); return Html::button($label, $this->clearOptions); } }
/** * 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->header !== null || !$this->multiple) { return parent::renderHeaderCellContent(); } else { return Html::checkbox($this->getHeaderCheckBoxName(), false, ['class' => 'select-on-check-all']); } }
/** * @inheritdoc */ protected function renderHeaderCellContent() { if ($this->header !== null || $this->label === null && $this->attribute === null) { return parent::renderHeaderCellContent(); } $label = $this->getHeaderCellLabel(); if ($this->encodeLabel) { $label = Html::encode($label); } if ($this->attribute !== null && $this->enableSorting && ($sort = $this->grid->dataProvider->getSort()) !== false && $sort->hasAttribute($this->attribute)) { return $sort->link($this->attribute, array_merge($this->sortLinkOptions, ['label' => $label])); } else { return $label; } }
/** * 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']); } }
/** * 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 = 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::checkBox($name, false, ['class' => 'select-on-check-all']); return "<label class=\"control-label\">" . Html::checkBox($name, false, ['class' => 'select-on-check-all']) . "<span class=\"text\"></span></label>"; } }
/** * 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 = 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 { $content = Html::tag('button', Html::checkBox($name, false, ['class' => 'select-on-check-all', 'data-target' => $this->name, 'data-checkall' => 1, 'data-parent-id' => $id]) . ' <span class="caret"></span>', ['type' => 'button', 'class' => 'btn btn-default dropdown-toggle', 'data-toggle' => 'dropdown']); $buttons = preg_replace_callback('/\\{([\\w\\-\\/]+)\\}/', function ($matches) use($model, $key, $index) { $name = $matches[1]; $module = \Yii::$app->user->can(\Yii::$app->controller->module->id . '/' . \Yii::$app->controller->id . '/' . $name); if ($module) { if (isset($this->buttons[$name])) { $url = $this->createUrl($name, $model, $key, $index); if (call_user_func($this->checkaccess, $url)) { return call_user_func($this->buttons[$name], $url, $model); } else { return ''; } } else { return ''; } } }, $this->template); if ($buttons == '') { return $buttons; } $content .= Html::tag('ul', $buttons, ['class' => 'dropdown-menu pull-right', 'role' => 'menu']); return Html::tag('div', $content, ['class' => 'dropdown']); } }