0

i m struggling with an issue on Magento 2.4.5 creating a custom module on admin. I have created a 2 column ui with a form and listing, which renders a grid on the admin, however, no matter what i have tried, i m not able to pass the initial url param i.e. entity_id/1 to the ajax request of the grid. I have used filter_url_params attribute on my xml, but still doesn't seem to have any affect on it.

My code looks like this

xxx_form.xml

        <insertListing name="XXXX_YYYY_item_listing" component="Magento_Customer/js/form/components/insert-listing">
            <settings>
                <dataLinks>
                    <exports>false</exports>
                    <imports>true</imports>
                </dataLinks>
                <externalProvider>XXXX_YYYY_item_listing.XXXX_YYYY_item_listing_data_source</externalProvider>
                <selectionsProvider>XXXX_YYYY_item_listing.XXXX_YYYY_item_listing.XXXX_YYYY_item_listing_columns.ids</selectionsProvider>
                <autoRender>true</autoRender>
                <dataScope>XXXX_YYYY_item_listing</dataScope>
                <ns>XXXX_YYYY_item_listing</ns>
                <exports>
                    <link name="entity_id">${ $.externalProvider }:params.parent_id</link>
                </exports>
                <imports>
                    <link name="entity_id">${ $.provider }:data.entity_id</link>
                </imports>
            </settings>
        </insertListing>

listing.xml

<listing>
    ...
    <dataSource name="XXXX_YYYY_item_listing_data_source" component="Magento_Ui/js/grid/provider">
        <settings>
            <filterUrlParams>
                <param name="entity_id">*</param>
            </filterUrlParams>
            <storageConfig>
                <param name="indexField" xsi:type="string">entity_id</param>
            </storageConfig>
            <updateUrl path="mui/index/render"/>
        </settings>
        <aclResource>XXXX_YYYY::YYYY</aclResource>
        <dataProvider name="XXXX_YYYY_item_listing_data_source"
                      class="XXXX\YYYY\Ui\Component\Listing\DataProvider">
            <settings>
                <requestFieldName>entity_id</requestFieldName>
                <primaryFieldName>entity_id</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    ...
</isting>

The generated url looks like this

https://magento2.localhost.com/admin_1qmg8u/mui/index/render/key/873ebb66c3e249554d98becb8e6242feebfa6231878f6013e987659ee02bdd66/?namespace=XXXX_YYYY_item_listing&sorting%5Bfield%5D=entity_id&sorting%5Bdirection%5D=asc&filters%5Bplaceholder%5D=true&paging%5BpageSize%5D=20&paging%5Bcurrent%5D=1&isAjax=true

while it should look like this

https://magento2.localhost.com/admin_1qmg8u/mui/index/render/key/873ebb66c3e249554d98becb8e6242feebfa6231878f6013e987659ee02bdd66/?namespace=XXXX_YYYY_item_listing&entity_id=1&sorting%5Bfield%5D=entity_id&sorting%5Bdirection%5D=asc&filters%5Bplaceholder%5D=true&paging%5BpageSize%5D=20&paging%5Bcurrent%5D=1&isAjax=true

1 Answer 1

0

Finally found the answer. The problem occured since in the form, in order to prefill the fields i had used an extra key in the data provider, resulting in having to modify the import tag as following

  <exports>
      <link name="entity_id">${ $.externalProvider }:params.parent_id</link>
  </exports>
  <imports>
      <link name="entity_id">${ $.provider }:data.MY_DATA_PROVIDER_KEY.entity_id</link>
  </imports>
1
  • can you give example MY_DATA_PROVIDER_KEY ?
    – Egi
    Commented Dec 9, 2023 at 6:48

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.