/** * Constructor * * @param AdapterInterface $adapter * @param DataSourceInterface $dataSource * @param ServiceManager $sm */ public function __construct(AdapterInterface $adapter, DataSourceInterface $dataSource, ServiceManager $sm) { $this->adapter = $adapter; $this->dataSource = $dataSource; $this->sm = $sm; $columnBag = $this->adapter->getColumnBag(); foreach ($this->dataSource->getFields() as $field) { $columnBag->add($field); } }
/** * {@inheritdoc} */ protected function onSortEvent(DataSourceInterface $dataSource) { for ($i = 0; $i < count($this->columnBag->getVisible()); $i++) { if (isset($this->parameters['iSortCol_' . $i])) { $offset = $this->parameters['iSortCol_' . $i]; $direction = $this->parameters['sSortDir_' . $i]; $column = $this->columnBag->getOffset($offset); $dataSource->addSort($column['field'], $direction); } } }