Skip to content

Instantly share code, notes, and snippets.

@popovserhii
Last active July 10, 2024 21:20
Show Gist options
  • Save popovserhii/43565f0732e069f0af2faced959b0671 to your computer and use it in GitHub Desktop.
Save popovserhii/43565f0732e069f0af2faced959b0671 to your computer and use it in GitHub Desktop.
Apply filters to DataSource of Datagrid
<?php
use ZfcDatagrid\Library\FilterHelper;
use Popov\DatagridBundle\Renderer\Json\Renderer;
$this->abstractFactory->setDataSource(...func_get_args());
$filterColumn = $this->abstractFactory->getFilterColumn();
$retriever = $this->abstractFactory->getRetriever();
// Apply filters
$filters = FilterHelper::merge($this->process(), $this->newFilters);
$filterGroup = (new Renderer())
->setIgnoredFilters($this->ignoredFilters)
->setIgnoredGroupsBy($this->ignoredGroupsBy)
->prepareFilters($filters);
$filterColumn->applyFilters($filterGroup);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment