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

asked Sep 7, 2020 at 9:05
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... 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

answered Sep 11, 2020 at 10:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.