0

I rephrased my question and got it working (adding filters to a custom grid, that was made with a custom data provider). See question and answer here: Create filterable admin grid from external database table

2
  • Try to put <filters name="listing_filters"/> in <listingToolbar /> tag above the <paging name="listing_paging"></paging> tag in your xml file. Commented Sep 8, 2020 at 8:15
  • I did and the filter options appear above the grid - but they dont apply to the grid, once I input some values to any filter field...
    – Mario
    Commented Sep 8, 2020 at 9:41

1 Answer 1

0

Ok, I finally found my mistake(?!) - I can get the applied filters in my data-provider php file by using the SessionManagerInterface:

use Magento\Framework\Session\SessionManagerInterface;

class YourClassname extents AbstractDataProvider
{
  protected $session;
  
    public function __construct(
        $name,
        $primaryFieldName,
        $requestFieldName,
        RequestInterface $request,
        UrlInterface $urlBuilder,
        Collection $collectionFactory,
        FilterBuilder $filterBuilder,
        array $meta = [],
        array $data = [],
        Data $helper,
        SessionManagerInterface $session
    ) {
        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
        $this->collection = $collectionFactory->load();
        $this->helper = $helper;
        $this->request = $request;
        $this->filterBuilder = $filterBuilder;
        $this->urlBuilder = $urlBuilder;
        $this->prepareUpdateUrl();
        $this->session=$session;
    }
      public function getData()
    {

        $this->session->start();

        $filters=$this->request->getParam('filters');
    }

If anyone faces same problems, feel free to ask.

Some more code from this module and (basically the same) question from me with solution can be found here: Create filterable admin grid from external database table

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.