本文整理汇总了PHP中yii\grid\ActionColumn::initDefaultButtons方法的典型用法代码示例。如果您正苦于以下问题:PHP ActionColumn::initDefaultButtons方法的具体用法?PHP ActionColumn::initDefaultButtons怎么用?PHP ActionColumn::initDefaultButtons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\grid\ActionColumn
的用法示例。
在下文中一共展示了ActionColumn::initDefaultButtons方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initDefaultButtons
/**
* Initializes the default button rendering callbacks.
*/
protected function initDefaultButtons()
{
parent::initDefaultButtons();
if (!isset($this->buttons['active'])) {
$this->buttons['active'] = function ($url, $model) {
return Html::a('<span onclick="admin_api.request({id:' . $model['id'] . ', model:\'' . lcfirst((new \ReflectionClass($model))->getShortName()) . '\', method:\'post\', attributes:{active:' . ($model['active'] ? '0' : '1') . '}})" class="glyphicon ' . ($model['active'] ? 'glyphicon-ok' : 'glyphicon-ban-circle') . ' " style="color: ' . ($model['active'] ? 'yellow' : 'gray') . ' "></span>', '', ['title' => $model['active'] ? 'Отключить' : 'Включить']);
};
}
}
示例2: initDefaultButtons
protected function initDefaultButtons()
{
parent::initDefaultButtons();
if (!isset($this->buttons['form-view'])) {
$this->buttons['form-view'] = function ($url, $model, $key) {
$options = array_merge(['title' => Yii::t('yii', 'Add'), 'aria-label' => Yii::t('yii', 'Add'), 'data-pjax' => '0'], $this->buttonOptions);
return Html::a('<span class="glyphicon glyphicon-wrench"></span>', $url, $options);
};
}
}
示例3: initDefaultButtons
protected function initDefaultButtons()
{
parent::initDefaultButtons();
if (!isset($this->actionName)) {
$this->actionName = 'disable';
}
if (!isset($this->buttons[$this->actionName])) {
$this->buttons[$this->actionName] = function ($url, $model, $key) {
$label = $model->{$this->stateAttribute} ? Yii::t('app', 'Enable') : Yii::t('app', 'Disable');
$options = array_merge($this->buttonOptions, ['title' => $label, 'aria-label' => $label, 'data-method' => 'post', 'data-pjax' => '0', 'class' => 'btn btn-block ' . ($model->{$this->stateAttribute} ? 'btn-success' : 'btn-danger')]);
if (isset($this->confirmation)) {
$options['data-confirm'] = $this->confirmation;
}
return Html::a('<span class="glyphicon glyphicon-ban-circle"></span> ' . $label, $url, $options);
};
}
}
示例4: initDefaultButtons
/**
* Initializes the default button rendering callbacks.
*/
protected function initDefaultButtons()
{
ActionAsset::register($this->grid->view);
parent::initDefaultButtons();
if (!isset($this->buttons['up'])) {
$this->buttons['up'] = function ($url) {
$options = ArrayHelper::merge(['title' => Yii::t('hass', 'Up'), 'aria-label' => Yii::t('hass', 'Up'), 'data-pjax' => '0'], $this->buttonOptions);
Html::addCssClass($options, "move-up");
return Html::a('<span class="glyphicon glyphicon-arrow-up"></span>', $url, $options);
};
}
if (!isset($this->buttons['down'])) {
$this->buttons['down'] = function ($url) {
$options = ArrayHelper::merge(['title' => Yii::t('hass', 'Down'), 'aria-label' => Yii::t('hass', 'Down'), 'data-pjax' => '0'], $this->buttonOptions);
Html::addCssClass($options, "move-down");
return Html::a('<span class="glyphicon glyphicon-arrow-down"></span>', $url, $options);
};
}
}