/** * 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() { parent::init(); $this->_module = Config::initModule(Module::classname()); }
/** * @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(); }
/** * @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]]; }