Пример #1
0
 /**
  * Initialize the grid view for dynagrid
  */
 protected function initGrid()
 {
     $dynagrid = '';
     $dynagridFilter = '';
     $dynagridSort = '';
     $model = new DynaGridSettings();
     if ($this->showPersonalize) {
         $this->setToggleButton('grid');
         if ($this->allowFilterSetting || $this->allowSortSetting) {
             $store = new DynaGridStore(['id' => $this->options['id'], 'category' => DynaGridStore::STORE_GRID, 'storage' => $this->storage, 'userSpecific' => $this->userSpecific]);
             if ($this->allowFilterSetting) {
                 $this->_model->filterId = $this->_filterId;
                 $this->_model->filterList = $store->getDtlList(DynaGridStore::STORE_FILTER);
             }
             if ($this->allowSortSetting) {
                 $dataProvider = $this->gridOptions['dataProvider'];
                 $sort = $dataProvider->getSort();
                 $sort->enableMultiSort = $this->enableMultiSort;
                 $dataProvider->setSort($sort);
                 $this->_model->sortId = $this->_sortId;
                 $this->_model->sortList = $store->getDtlList(DynaGridStore::STORE_SORT);
             }
         }
         $dynagrid = $this->render($this->_module->configView, ['model' => $this->_model, 'toggleButtonGrid' => $this->toggleButtonGrid, 'id' => $this->_gridModalId, 'allowThemeSetting' => $this->allowThemeSetting, 'allowFilterSetting' => $this->allowFilterSetting, 'allowSortSetting' => $this->allowSortSetting]);
     }
     $model->dynaGridId = $this->options['id'];
     $model->storage = $this->storage;
     $model->userSpecific = $this->userSpecific;
     if ($this->showFilter) {
         $this->setToggleButton('filter');
         $model->category = DynaGridStore::STORE_FILTER;
         $model->key = $this->_filterKey;
         $model->data = array_filter($this->gridOptions['filterModel']->attributes);
         $dynagridFilter = DynaGridDetail::widget(['id' => $this->_filterModalId, 'model' => $model, 'toggleButton' => $this->toggleButtonFilter, 'submitMessage' => $this->submitMessage, 'deleteMessage' => $this->deleteMessage, 'messageOptions' => $this->messageOptions, 'deleteConfirmation' => $this->deleteConfirmation, 'isPjax' => $this->_isPjax, 'pjaxId' => $this->_pjaxId]);
     }
     if ($this->showSort) {
         $this->setToggleButton('sort');
         $model->category = DynaGridStore::STORE_SORT;
         $model->key = $this->_sortKey;
         $model->data = $this->gridOptions['dataProvider']->getSort()->getOrders();
         $dynagridSort = DynaGridDetail::widget(['id' => $this->_sortModalId, 'model' => $model, 'toggleButton' => $this->toggleButtonSort, 'submitMessage' => $this->submitMessage, 'deleteMessage' => $this->deleteMessage, 'messageOptions' => $this->messageOptions, 'deleteConfirmation' => $this->deleteConfirmation, 'isPjax' => $this->_isPjax, 'pjaxId' => $this->_pjaxId]);
     }
     $tags = ArrayHelper::getValue($this->gridOptions, 'replaceTags', []);
     $tags += ['{dynagrid}' => $dynagrid, '{dynagridFilter}' => $dynagridFilter, '{dynagridSort}' => $dynagridSort];
     $this->gridOptions['replaceTags'] = $tags;
     $this->registerAssets();
 }
Пример #2
0
 /**
  * Deletes grid configuration settings from store
  *
  * @return void
  * @throws \yii\base\InvalidConfigException
  */
 public function deleteSettings()
 {
     $master = new DynaGridStore(['id' => $this->dynaGridId, 'category' => DynaGridStore::STORE_GRID, 'storage' => $this->storage, 'userSpecific' => $this->userSpecific]);
     $config = $this->storage == DynaGrid::TYPE_DB ? null : $master->fetch();
     $master->deleteConfig($this->category, $config);
     $this->store->delete();
 }