/** * {@inheritdoc} */ protected function processSessionData() { parent::processSessionData(); // Columns if (($columnIds = $this->get(self::REQUEST_QUERY_COLUMNS)) !== null) { if (count((array) $columnIds)) { foreach ($this->columns as $column) { if (!in_array($column->getId(), $columnIds)) { $column->setVisible(false); } else { $column->setVisible(true); } } } } }
/** * @param string $section * @param \APY\DataGridBundle\Grid\Grid $grid * @param \APY\DataGridBundle\Grid\Column\Column $param * @return string */ public function getGridUrl($section, $grid, $param = null) { $separator = strpos($grid->getRouteUrl(), '?') ? '&' : '?'; switch ($section) { case 'order': if ($param->isSorted()) { return $grid->getRouteUrl() . $separator . $grid->getHash() . '[' . Grid::REQUEST_QUERY_ORDER . ']=' . $param->getId() . '|' . ($param->getOrder() == 'asc' ? 'desc' : 'asc'); } else { return $grid->getRouteUrl() . $separator . $grid->getHash() . '[' . Grid::REQUEST_QUERY_ORDER . ']=' . $param->getId() . '|asc'; } case 'page': return $grid->getRouteUrl() . $separator . $grid->getHash() . '[' . Grid::REQUEST_QUERY_PAGE . ']=' . $param; case 'limit': return $grid->getRouteUrl() . $separator . $grid->getHash() . '[' . Grid::REQUEST_QUERY_LIMIT . ']='; case 'reset': return $grid->getRouteUrl() . $separator . $grid->getHash() . '[' . Grid::REQUEST_QUERY_RESET . ']='; } }
/** * @param \Symfony\Component\DependencyInjection\Container $container * @param string $id set if you are using more then one grid inside controller */ public function __construct($container, $id = '') { parent::__construct($container, $id); }
/** * {@inheritdoc} */ public function getGrid() { $config = $this->getGridConfig(); $grid = new Grid($this->container, $config->getName(), $config); foreach ($this->columns as $column) { $grid->addColumn($column); } if (!empty($this->actions)) { foreach ($this->actions as $columnId => $actions) { foreach ($actions as $action) { $grid->addRowAction($action); } } } $grid->initialize(); return $grid; }
/** * @return array */ public function getRouteParameters() { if ($this->request->query->has('grid')) { $this->routeParameters['grid'] = $this->request->query->get('grid'); } return parent::getRouteParameters(); }