/** * Initializes the object * * @throws InvalidConfigException */ public function init() { $this->_module = Config::initModule(Module::classname()); $this->_isMaster = $this->category == self::STORE_GRID ? true : false; if ($this->_module == null || !$this->_module instanceof Module) { throw new InvalidConfigException('The "dynagrid" module MUST be setup in your Yii configuration file and assigned to "\\kartik\\dynagrid\\Module" class.'); } if (!isset($this->id)) { throw new InvalidConfigException('The dynagrid "id" property must be entered.'); } $this->setKey(); }
/** * Initializes the widget * * @throws InvalidConfigException * @return void */ public function init() { parent::init(); if (empty($this->options['id'])) { throw new InvalidConfigException("You must setup a unique identifier for DynaGrid within \"options['id']\"."); } $this->_module = Config::initModule(Module::classname()); $this->_gridModalId = $this->options['id'] . '-grid-modal'; $this->_filterModalId = $this->options['id'] . '-filter-modal'; $this->_sortModalId = $this->options['id'] . '-sort-modal'; $this->_filterKey = $this->options['id'] . '-filter-key'; $this->_sortKey = $this->options['id'] . '-sort-key'; $this->_pjaxId = $this->options['id'] . '-pjax'; foreach ($this->_module->dynaGridOptions as $key => $setting) { if (is_array($setting) && !empty($setting) && !empty($this->{$key})) { $this->{$key} = ArrayHelper::merge($setting, $this->{$key}); } elseif (!isset($this->{$key})) { $this->{$key} = $setting; } } if (empty($this->columns) || !is_array($this->columns)) { throw new InvalidConfigException("The 'columns' configuration must be setup as a valid array."); } if (empty($this->gridOptions['dataProvider']) && empty($this->gridOptions['filterModel'])) { throw new InvalidConfigException("You must setup either the gridOptions['filterModel'] or gridOptions['dataProvider']."); } if (!empty($this->gridOptions['filterModel']) && !method_exists($this->gridOptions['filterModel'], 'search')) { throw new InvalidConfigException("The gridOptions['filterModel'] must implement a 'search' method in order to apply saved filters."); } if (empty($this->gridOptions['dataProvider'])) { $this->initDataProvider($this->gridOptions['filterModel']); } if (empty($this->gridOptions['filterModel'])) { $this->showFilter = false; $this->allowFilterSetting = false; } if (empty($this->theme)) { $this->theme = $this->_module->defaultTheme; } if (empty($this->_pageSize)) { $this->_pageSize = $this->_module->defaultPageSize; } $this->_requestSubmit = $this->options['id'] . '-dynagrid'; $this->_model = new DynaGridConfig(); $this->_isSubmit = !empty($_POST[$this->_requestSubmit]) && $this->_model->load(Yii::$app->request->post()) && $this->_model->validate(); $this->_store = new DynaGridStore(['id' => $this->options['id'], 'storage' => $this->storage, 'userSpecific' => $this->userSpecific]); $this->prepareColumns(); $this->configureColumns(); $this->applyGridConfig(); $this->_isPjax = ArrayHelper::getValue($this->gridOptions, 'pjax', false); if ($this->_isPjax) { $this->gridOptions['pjaxSettings']['options']['id'] = $this->_pjaxId; } $this->initGrid(); }
/** * @inheritdoc */ public function init() { if (empty($this->model) || !$this->model instanceof Model) { throw new InvalidConfigException("You must enter a valid 'model' for DynaGridDetail."); } parent::init(); $this->_module = Config::initModule(Module::classname()); $this->_requestSubmit = $this->options['id'] . '-dynagrid-detail'; $this->_isSubmit = !empty($_POST[$this->_requestSubmit]) && $this->model->load(Yii::$app->request->post()) && $this->model->validate(); $this->registerAssets(); }
<?php /** * @copyright Copyright © Kartik Visweswaran, Krajee.com, 2015 * @package yii2-dynagrid * @version 1.4.2 */ use yii\helpers\Html; use yii\helpers\Url; use yii\helpers\ArrayHelper; use kartik\form\ActiveForm; use yii\bootstrap\Modal; use kartik\sortable\Sortable; use kartik\select2\Select2; use kartik\dynagrid\Module; $module = Module::fetchModule(); $listOptions = ['class' => 'form-control dynagrid-detail-list']; $data = $model->getDtlList(); if (count($data) == 0) { $listOptions['prompt'] = Yii::t('kvdynagrid', 'Select...', ['category' => $model->category]); } $dataConfig = print_r($model->data, true); $form = ActiveForm::begin(); echo $form->field($model, 'name', ['addon' => ['append' => ['asButton' => true, 'content' => Html::button('<span class="glyphicon glyphicon-ok"></span>', ['title' => Yii::t('kvdynagrid', 'Save'), 'class' => "dynagrid-detail-save btn btn-primary"]) . Html::button('<span class="glyphicon glyphicon-remove"></span>', ['title' => Yii::t('kvdynagrid', 'Delete'), 'class' => "dynagrid-detail-delete btn btn-danger"])]]])->textInput(['class' => 'form-control dynagrid-detail-name'])->hint(Yii::t('kvdynagrid', "Set a name to save the state of your current grid {category}. You can alternatively select a saved {category} from the list below to edit or delete.", ['category' => $model->category])); echo $form->field($model, 'editId')->listBox($data, $listOptions); //$form->field($model, 'dataConfig')->textArea(['class'=>'form-control dynagrid-settings-text', 'readOnly'=>true]) ?> <div class="dynagrid-settings-text"><?php echo $model->getDataConfig(); ?> </div>
/** * @inheritdoc */ public function init() { parent::init(); $this->_module = Config::initModule(Module::classname()); }
/** * @inheritdoc */ public function rules() { $this->_module = Config::initModule(Module::classname()); return [[['id', 'hiddenColumns', 'visibleColumns', 'pageSize', 'filterId', 'sortId', 'theme', 'hiddenKeys', 'visibleKeys'], 'safe'], [['pageSize', 'theme'], 'required'], ['pageSize', 'integer', 'min' => $this->_module->minPageSize, 'max' => $this->_module->maxPageSize], ['pageSize', 'default', 'value' => $this->_module->defaultPageSize], ['theme', 'default', 'value' => $this->_module->defaultTheme]]; }