Skip to content

How to show data in grid based on url parameter in magento 2 custom form?

I created a custom form to save the data(category – table_category). In the form page i have a grid which shows Faqs related to the category. Currently i am getting all the faqs(table faq), which are not filtered based on categories.
enter image description here

I am passing the category id like below to the listing.

<fieldset name="faq_lists">
    <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="label" xsi:type="string" translate="true">Faq List (Listing)</item>
        </item>
    </argument>
    <insertListing name="faq_lists">
        <settings>
            <externalData>id</externalData>
            <dataLinks>
                <exports>false</exports>
                <imports>true</imports>
            </dataLinks>
            <autoRender>true</autoRender>
            <selectionsProvider>
                ayakil_faq_faq_listing.ayakil_faq_faq_listing_data_source.columns.ids
            </selectionsProvider>
            <dataScope>ayakil_faq_faq_listing</dataScope>
            <ns>ayakil_faq_faq_listing</ns>
            <exports>
                <link name="faq_category_id">${ $.externalProvider }:params.faq_category_id</link>
            </exports>
        </settings>
    </insertListing>
</fieldset>

And in the listing xml i added

<filterUrlParams>
    <param name="faq_category_id">*</param>
</filterUrlParams>

But still all the faqs show in the grid. Not based on the category id its not filtering. How can i do this task?