public function init() { parent::init(); if (!$this->filterInputOptions['id']) { $this->filterInputOptions['id'] = $this->attribute; } if (!$this->filter && $this->grid->filterModel) { $this->filter = \Yii::createObject(['class' => $this->comboClass, 'attribute' => $this->attribute, 'model' => $this->grid->filterModel, 'formElementSelector' => 'td'])->run(); } }
public function init() { parent::init(); if (!empty($this->grid->filterModel)) { if (!$this->filterInputOptions['id']) { $this->filterInputOptions['id'] = $this->attribute; } if (!$this->filter) { $this->filter = AccountCombo::widget(['attribute' => $this->attribute, 'model' => $this->grid->filterModel, 'formElementSelector' => 'td']); } } }
public function getDataCellValue($model, $key, $index) { $itemName = 'bss_' . $this->attribute . '_' . $key; $modelPkName = reset($model::primaryKey()); if ($this->url) { Yii::$app->view->registerJs(<<<JS var input = \$('input[name="{$itemName}"]'); input.on('switchChange.bootstrapSwitch', function(event, state) { var elem = \$(this); var data = {}; data['{$model->formName()}'] = {}; data['{$model->formName()}']['{$modelPkName}'] = '{$key}'; data['{$model->formName()}']['{$this->attribute}'] = state ? 1 : 0; jQuery.ajax({ 'type': 'POST', 'url': '{$this->url}', 'data': data }).done(function(resp) { var options = { text: resp.text, buttons: { sticker: false }, styling: 'bootstrap3' }; if (resp.success === false) { options.type = 'error'; options.icon = 'fa fa-fw fa-exclamation-triangle'; elem.bootstrapSwitch('toggleReadonly'); } else { options.type = 'success'; options.icon = 'fa fa-fw fa-check-circle'; } if (typeof PNotify != "undefined") { new PNotify(options); } else { alert(resp.text); } }); }); JS ); } return BootstrapSwitch::widget(['name' => $itemName, 'options' => $this->options, 'pluginOptions' => ArrayHelper::merge(['state' => (bool) parent::getDataCellValue($model, $key, $index)], $this->pluginOptions)]); }
/** * Sets visibility and default behaviour for value and filter when visible. */ public function init() { parent::init(); $this->visible = Yii::$app->user->can('support'); if (!$this->visible) { return; } if (!$this->sortAttribute) { $this->sortAttribute = $this->nameAttribute; } if ($this->value === null) { $this->value = function ($model) { return Html::a($model->{$this->nameAttribute}, ['@client/view', 'id' => $model->{$this->idAttribute}]); }; } if (!empty($this->grid->filterModel)) { if (!$this->filterInputOptions['id']) { $this->filterInputOptions['id'] = $this->attribute; } if (!$this->filter) { $this->filter = ClientCombo::widget(['attribute' => $this->attribute, 'model' => $this->grid->filterModel, 'formElementSelector' => 'td', 'clientType' => $this->clientType]); } } }