Skip to content

Get selected values from Grid which is created by insertListing /button component inside a modal component to display on parent

I have add this button to display a grid inside a custom UI form, but cannot able to get in Controller  Data of which is selected from the grid

 <button name="insert_listing_example_modal_button" component="Magento_Ui/js/form/components/button">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="buttonClasses" xsi:type="string">open-url-rewrite-listing-modal-button</item>
                <item name="actions" xsi:type="array">
                    <item name="0" xsi:type="array">
                        <item name="targetName" xsi:type="string">${ $.parentName}.url_rewrite_listing_modal.url_rewrite_listing_loader</item>
                        <item name="actionName" xsi:type="string">destroyInserted</item>
                    </item>
                    <item name="1" xsi:type="array">
                        <item name="targetName" xsi:type="string">${ $.parentName}.url_rewrite_listing_modal</item>
                        <item name="actionName" xsi:type="string">openModal</item>
                    </item>
                    <item name="2" xsi:type="array">
                        <item name="targetName" xsi:type="string">${ $.parentName}.url_rewrite_listing_modal.url_rewrite_listing_loader</item>
                        <item name="actionName" xsi:type="string">render</item>
                    </item>
                </item>
            </item>
        </argument>
        <settings>
            <title translate="true">Open URL Rewrite Listing Modal</title>
        </settings>
    </button>
    <modal name="url_rewrite_listing_modal">
        <settings>
            <options>
                <option name="title" xsi:type="string">URL Rewrite Listing Modal</option>
            </options>
        </settings>
        <insertForm name="url_rewrite_listing_loader">
            <settings>
                <formSubmitType>ajax</formSubmitType>
                <renderUrl path="mui/index/render">
                    <param name="handle">url_rewrite_listing</param>
                    <param name="buttons">1</param>
                </renderUrl>
                <loading>false</loading>
                <toolbarContainer>${ $.parentName }</toolbarContainer>
                <ns>url_rewrite_listing</ns>
            </settings>
        </insertForm>
    </modal>

i tried with <insertListing> but still didn’t get selected data in Controller,

<?xml version="1.0"?>

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">customurlrewrite_form.customurlrewrite_form_data_source</item>
            <item name="deps" xsi:type="string">customurlrewrite_form.customurlrewrite_form_data_source</item>
        </item>
        <item name="label" xsi:type="string" translate="true">General Information</item>
        <item name="config" xsi:type="array">
            <item name="dataScope" xsi:type="string">data</item>
            <item name="namespace" xsi:type="string">customurlrewrite_form</item>
        </item>
        <item name="spinner" xsi:type="string">general_information</item>
        <item name="buttons" xsi:type="array">
            <item name="back" xsi:type="string">VendorCustomUrlRewriteBlockAdminhtmlIndexEditButtonBack</item>
            <item name="delete" xsi:type="string">VendorCustomUrlRewriteBlockAdminhtmlIndexEditButtonDelete
            </item>
            <item name="reset" xsi:type="string">VendorCustomUrlRewriteBlockAdminhtmlIndexEditButtonReset</item>
            <item name="save" xsi:type="string">VendorCustomUrlRewriteBlockAdminhtmlIndexEditButtonSave</item>
        </item>
        <item name="template" xsi:type="string">templates/form/collapsible</item>
    </argument>
    <dataSource name="customurlrewrite_form_data_source">
        <argument name="dataProvider" xsi:type="configurableObject">
            <argument name="class" xsi:type="string">VendorCustomUrlRewriteModelDataProvider</argument>
            <argument name="name" xsi:type="string">customurlrewrite_form_data_source</argument>
            <argument name="primaryFieldName" xsi:type="string">url_id</argument>
            <argument name="requestFieldName" xsi:type="string">url_id</argument>
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="submit_url" xsi:type="url" path="*/*/save"/>
                </item>
            </argument>
        </argument>
        <argument name="data" xsi:type="array">
            <item name="js_config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
            </item>
        </argument>
    </dataSource>
    <fieldset name="general_information">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="collapsible" xsi:type="boolean">false</item>
                <item name="label" xsi:type="string" translate="true">Url Rewrite Information</item>
                <item name="sortOrder" xsi:type="number">10</item>
            </item>
        </argument>
        <field name="store_code">
            <argument name="data" xsi:type="array">
                <item name="options" xsi:type="object">VendorCustomUrlRewriteModelSelectSourceStoreCodes</item>
                <item name="config" xsi:type="array">
                    <item name="componentType" xsi:type="string">field</item>
                    <item name="formElement" xsi:type="string">select</item>
                    <item name="label" xsi:type="string">Store Code</item>
                    <item name="visible" xsi:type="boolean">true</item>
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="source" xsi:type="string">store_code</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                    </item>
                </item>
            </argument>
        </field>
        <field name="url_key">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Url Key</item>
                    <item name="formElement" xsi:type="string">input</item>
                    <item name="source" xsi:type="string">url_key</item>
                    <item name="dataScope" xsi:type="string">url_key</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                    </item>
                </item>
            </argument>
        </field>
        <field name="url_rewrite_id">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="dataType" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Url Rewrite Id</item>
                    <item name="formElement" xsi:type="string">input</item>
                    <item name="source" xsi:type="string">url_rewrite_id</item>
                    <item name="dataScope" xsi:type="string">url_rewrite_id</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">true</item>
                        <item name="validate-number" xsi:type="boolean">true</item>
                    </item>
                </item>
            </argument>
        </field>
        **<insertListing name="url_rewrite_listing" >
            <settings>
                <dataLinks>
                    <exports>false</exports>
                    <imports>true</imports>
                </dataLinks>
                <autoRender>true</autoRender>
                <selectionsProvider>url_rewrite_listing.url_rewrite_listing_data_source.columns.ids</selectionsProvider>
                <dataScope>url_rewrite_listing</dataScope>
                <ns>url_rewrite_listing</ns>
            </settings>
        </insertListing>**
</form>

Got only 3 index only, missed 4th index

enter image description here

am i missing Something?????