2

I have a custom product listing grid, on clicking add products, I have created a (slider) modal, Where I check the products from another grid and click add selected products, then the selected items should get reflected in my parent grid; but the when I close the modal, the selected items are not getting reflected. Please provide your suggestions. Thank you!

            <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">test_modulename_functionality.test_modulename_functionality_data_source</item>
                    <item name="deps" xsi:type="string">test_modulename_functionality.test_modulename_functionality_data_source</item>
                </item>
                <item name="label" xsi:type="string" translate="true">Campaigns</item>
                <item name="config" xsi:type="array">
                    <item name="dataScope" xsi:type="string">data</item>
                    <item name="namespace" xsi:type="string">test_modulename_functionality</item>
                </item>
                <item name="template" xsi:type="string">templates/form/collapsible</item>
            </argument>
            <settings>
                <buttons>
                    <button name="delete" class="Modulename\Functinality\Block\Adminhtml\Edit\DeleteButton"/>
                    <button name="save_and_continue" class="Modulename\Functinality\Block\Adminhtml\Edit\SaveAndContinueButton"/>
                    <button name="reset" class="Modulename\Functinality\Block\Adminhtml\Edit\ResetButton"/>
                    <button name="save" class="Modulename\Functinality\Block\Adminhtml\Edit\SaveButton"/>
                    <button name="back">
                        <url path="*/*/"/>
                        <class>back</class>
                        <label translate="true">Back</label>
                    </button>
                </buttons>
                <namespace>test_modulename_functionality</namespace>
                <dataScope>data</dataScope>
                <deps>
                    <dep>test_modulename_functionality.test_modulename_functionality_source</dep>
                </deps>
            </settings>
            <dataSource name="test_modulename_functionality_data_source">
                <argument name="dataProvider" xsi:type="configurableObject">
                    <argument name="class" xsi:type="string">Modulename\Functinality\Model\Campaigns\DataProvider</argument>
                    <argument name="name" xsi:type="string">test_modulename_functionality_data_source</argument>
                    <argument name="primaryFieldName" xsi:type="string">functionality_id</argument>
                    <argument name="requestFieldName" xsi:type="string">functionality_id</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>
                <settings>
                    <submitUrl path="module_functionalitymanagement/functionalitys/save"/>
                </settings>
            </dataSource>
           <fieldset name="assign_products" sortOrder="50">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="label" xsi:type="string" translate="true">Map Products</item>
                        <item name="content" xsi:type="string" translate="true">This is an auto generated field</item>
                        <item name="collapsible" xsi:type="boolean">true</item>
                        <item name="sortOrder" xsi:type="number">40</item>
                    </item>
                </argument>
                <modal name="functionality_associated_products_listing">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="onCancel" xsi:type="string">actionCancel</item>
                            <item name="options" xsi:type="array">
                                <item name="buttons" xsi:type="array">
                                    <item name="0" xsi:type="array">
                                        <item name="text" xsi:type="string">Cancel</item>
                                        <item name="class" xsi:type="string">action-secondary</item>
                                        <item name="actions" xsi:type="array">
                                            <item name="0" xsi:type="string">actionCancel</item>
                                        </item>
                                    </item>
                                    <item name="1" xsi:type="array">
                                        <item name="text" xsi:type="string">Select Products</item>
                                        <item name="class" xsi:type="string">action-primary</item>
                                        <item name="actions" xsi:type="array">
                                            <item name="0" xsi:type="string">actionDone</item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </argument>
                    <insertListing name="map_associated_products">
                        <settings>
                            <externalProvider>test_functionality_product_mapping_listing.test_functionality_product_mapping_listing_data_source</externalProvider>
                            <selectionsProvider>test_functionality_product_mapping_listing.test_functionality_product_mapping_listing.test_functionality_product_mapping_listing_columns.ids</selectionsProvider>
                            <autoRender>true</autoRender>
                            <dataScope>test_functionality_product_mapping_listing</dataScope>
                            <ns>test_functionality_product_mapping_listing</ns>
                            <exports>
                                <link name="entityId">${ $.externalProvider }:params.entity_id</link>
                            </exports>
                        </settings>
                    </insertListing>
                </modal>
                <button name="modal_button">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="title" xsi:type="string">Map Products</item>
                            <item name="align" xsi:type="string">left</item>
                            <item name="actions" xsi:type="array">
                                <item name="0" xsi:type="array">
                                    <item name="targetName" xsi:type="string">${ $.parentName}.functionality_associated_products_listing</item>
                                    <item name="actionName" xsi:type="string">openModal</item>
                                </item>
                            </item>
                        </item>
                    </argument>
                </button>
                <insertListing name="functionality_associated_products">
                    <argument name="data" xsi:type="array">
                        <item name="config" xsi:type="array">
                            <item name="externalTransfer" xsi:type="boolean">true</item>
                        </item>
                    </argument>
                    <settings>
                        <externalProvider>test_functionality_product_mapping_listing.test_functionality_product_mapping_listing_data_source</externalProvider>
                        <autoRender>true</autoRender>
                        <ns>test_functionality_product_mapping</ns>
                        <imports>
                            <link name="entityId">${ $.provider }:data.entity_id</link>
                        </imports>
                    </settings>
                </insertListing>
            </fieldset>
        </form>
  • What have you defined in the "export" child item of insertListing? Can you update your answer that shows whole code of "insertListing" tag in your xml? – Prachi Saxena Jan 31 at 6:35
  • Hi @PrachiSaxena I have updated the question with the whole code now. – Abhilash Acharya Feb 2 at 16:23
  • Hi Abhilash Please check the following answer: magento.stackexchange.com/a/292029/59216 Don't forget to upvote! :) – Milind Singh Oct 8 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.