I want to create a link to a custom grid in my admin with pre-defined filters. The grid is made with a UI Listing Component (XML) and it has a column called form_id
that is setup like this:
<column name="form_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="label" xsi:type="string" translate="true">Form id</item>
</item>
</argument>
</column>
The grid works just fine. I can apply the filter and everything works well. The grid gets nicely updated with a XHR request.
However... I want to be able to have a filters' value pre-defined at some point. For example, I want to be able to open the grid when it's filtered on ID=3.
So I already tried loading the page with the same URL parameters as the XHR-request, as well as simply adding the only required parameters:
?namespace=form_response_listing&search=&filters[placeholder]=true&filters[form_id][from]=3&filters[form_id][to]=3&paging[pageSize]=20&paging[current]=1
As well as:
?filters[form_id][from]=3&filters[form_id][to]=3
Both with no success. So how Can I pre-fill filters by using the URL?
Edit:
I'm not sure if this is a duplicate of the other question (as mentioned in the comments below). In my case, I'm using a virtual type as collection for my grid:
<virtualType name="Vendor\Module\Model\ResourceModel\Response\Grid\Collection"
type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">vendormodule_form_response</argument>
<argument name="resourceModel" xsi:type="string">Vendor\Module\Model\ResourceModel\Response</argument>
</arguments>
</virtualType>
So it's not that I have a physical Block class for my grid widget, it's purely created with a UI Component listing XML.
Nevertheless, I'll check anyway if the question referred to will help my use case.
prepareColumns
method.