protected function makeGridWidget() { $config = $this->makeConfig((array) $this->config); $config->dataLocker = '#' . $this->getId('dataLocker'); $grid = new Grid($this->controller, $config); $grid->alias = $this->alias . 'Grid'; $grid->bindEvent('grid.autocomplete', [$this, 'getAutocompleteValues']); $grid->bindEvent('grid.dataSource', [$this, 'getDataSourceValues']); return $grid; }
public function prepareGrid() { $fromCode = post('locale_from', null); $toCode = post('locale_to', Locale::getDefault()->code); /* * Page vars */ $this->vars['hideTranslated'] = post('hide_translated', false); $this->vars['defaultLocale'] = Locale::getDefault(); $this->vars['locales'] = Locale::all(); $this->vars['selectedFrom'] = $selectedFrom = Locale::findByCode($fromCode); $this->vars['selectedTo'] = $selectedTo = Locale::findByCode($toCode); /* * Make grid config, make default column read only */ $config = $this->makeConfig('config_grid.yaml'); $config->data = $this->getGridData($selectedFrom, $selectedTo); if (!$selectedFrom) { $config->columns['from']['readOnly'] = true; } if (!$selectedTo) { $config->columns['to']['readOnly'] = true; } /* * Make grid widget */ $widget = new Grid($this, $config); $widget->bindEvent('grid.dataChanged', function ($action, $changes) { if ($action == 'remove') { $this->removeGridData($changes); } else { $this->updateGridData($changes); } }); $widget->bindToController(); $this->vars['grid'] = $widget; }