本文整理汇总了PHP中yii\grid\Column::renderHeaderCellContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Column::renderHeaderCellContent方法的具体用法?PHP Column::renderHeaderCellContent怎么用?PHP Column::renderHeaderCellContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\grid\Column
的用法示例。
在下文中一共展示了Column::renderHeaderCellContent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderHeaderCellContent
/**
* 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']);
}
}
示例2: renderHeaderCellContent
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);
}
}
示例3: renderHeaderCellContent
/**
* 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();
}
}
示例4: 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);
}
}
示例5: renderHeaderCellContent
/**
* 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']);
}
}
示例6: renderHeaderCellContent
/**
* @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;
}
}
示例7: renderHeaderCellContent
/**
* 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']);
}
}
示例8: renderHeaderCellContent
/**
* 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>";
}
}
示例9: renderHeaderCellContent
/**
* 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']);
}
}