1

I've refer the assign source code ui form and with same exact functionality i wanted to add my own store by selection.

I've applied the same code but does not reflect the selected item in the dynamic row component.

For Exact Issue, You can also refer to this link. https://imgur.com/a/kbna2vf

And it should be something like this : enter image description here

below is my code for the uiform which is manage_holiday_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<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">manage_holiday_form.manageholiday_form_data_source</item>
        </item>
        <item name="label" xsi:type="string" translate="true">General Information</item>
        <item name="template" xsi:type="string">templates/form/collapsible</item>
    </argument>
    <settings>
        <buttons>
            <button name="back">
                <url path="*/*/index"/>
                <class>back</class>
                <label translate="true">Back</label>
            </button>
            <button name="reset">
                <class>reset</class>
                <label translate="true">Reset</label>
            </button>
            <button name="save">
                <class>save primary</class>
                <label translate="true">Save</label>
            </button>
        </buttons>
        <namespace>manage_holiday_form</namespace>
        <dataScope>data</dataScope>
        <deps>
            <dep>manage_holiday_form.manageholiday_form_data_source</dep>
        </deps>
    </settings>
    <dataSource name="manageholiday_form_data_source">
        <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="*/*/save"/>
        </settings>
        <dataProvider class="Vendor\StorePickup\Ui\DataProvider\StoreHolidayDataProvider" name="manageholiday_form_data_source">
            <settings>
                <requestFieldName>entity_id</requestFieldName>
                <primaryFieldName>entity_id</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <fieldset name="general">
        <settings>
            <label translate="true">Holiday Information</label>
        </settings>
        <field name="entity_id" formElement="input">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">block</item>
                </item>
            </argument>
            <settings>
                <dataType>text</dataType>
                <visible>false</visible>
                <dataScope>entity_id</dataScope>
            </settings>
        </field>

        <field name="holiday_name" formElement="input" sortOrder="20">
            <settings>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">false</rule>
                </validation>
                <dataType>text</dataType>
                <label translate="true">Holiday Name</label>
            </settings>
        </field>

        <field formElement="checkbox" name="is_range" sortOrder="30">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="default" xsi:type="number">0</item>
                </item>
            </argument>
            <settings>
                <dataScope>is_range</dataScope>
                <label translate="true">Use Holiday In Range</label>
            </settings>
            <formElements>
                <checkbox>
                    <settings>
                        <valueMap>
                            <map name="false" xsi:type="string">0</map>
                            <map name="true" xsi:type="string">1</map>
                        </valueMap>
                        <prefer>toggle</prefer>
                    </settings>
                </checkbox>
            </formElements>
        </field>

        <field name="holiday_date" formElement="date" component="Vendor_StorePickup/js/form/element/date" sortOrder="40">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">store</item>
                    <item name="options" xsi:type="array">
                        <item name="dateFormat" xsi:type="string">yy-mm-dd</item>
                        <item name="outputDateFormat" xsi:type="string">yy-mm-dd</item>
                    </item>
                </item>
            </argument>
            <settings>
                <validation>
                    <rule name="validate-date" xsi:type="boolean">true</rule>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
                <dataType>text</dataType>
                <label translate="true">Holiday Date</label>
                <visible>false</visible>
                <imports>
                    <link name="useSingleDate">${$.parentName}.is_range:checked</link>
                </imports>
                <dataScope>holiday_date</dataScope>
            </settings>
        </field>

        <field name="holiday_start" formElement="date" component="Vendor_StorePickup/js/form/element/date" sortOrder="50">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">store</item>
                    <item name="options" xsi:type="array">
                        <item name="dateFormat" xsi:type="string">yy-mm-dd</item>
                        <item name="outputDateFormat" xsi:type="string">yy-mm-dd</item>
                    </item>
                </item>
            </argument>
            <settings>
                <validation>
                    <rule name="validate-date" xsi:type="boolean">true</rule>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
                <dataType>text</dataType>
                <label translate="true">Holiday Start</label>
                <visible>false</visible>
                <imports>
                    <link name="shouldDisplay">${$.parentName}.is_range:checked</link>
                </imports>
                <dataScope>holiday_start</dataScope>
            </settings>
        </field>

        <field name="holiday_end" formElement="date" component="Vendor_StorePickup/js/form/element/date" sortOrder="60">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="source" xsi:type="string">store</item>
                    <item name="options" xsi:type="array">
                        <item name="dateFormat" xsi:type="string">yy-mm-dd</item>
                        <item name="outputDateFormat" xsi:type="string">yy-mm-dd</item>
                    </item>
                </item>
            </argument>
            <settings>
                <validation>
                    <rule name="validate-date" xsi:type="boolean">true</rule>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
                <dataType>text</dataType>
                <label translate="true">Holiday End</label>
                <visible>false</visible>
                <imports>
                    <link name="shouldDisplay">${$.parentName}.is_range:checked</link>
                </imports>
                <dataScope>holiday_end</dataScope>
            </settings>
        </field>

    </fieldset>
    
    <!-- <fieldset name="assign_stores">
        <settings>
            <label translate="true">Add Holiday to Store</label>
        </settings>
        <container name="assign_stores_container" >
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="sortOrder" xsi:type="number">170</item>
                </item>
            </argument>

            <htmlContent name="html_content">
                <argument name="block" xsi:type="object">Vendor\StorePickup\Block\Adminhtml\Stores\AssignStores</argument>
            </htmlContent>
        </container>
    </fieldset> -->

    <fieldset name="assign_stores" sortOrder="50">
        <settings>
            <label translate="true">Assign Stores</label>
            <collapsible>true</collapsible>
            <opened>true</opened>
            <dataScope>assign_stores</dataScope>
        </settings>
        <container name="assign_stores_container" component="Magento_Ui/js/form/components/group" sortOrder="10">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="formElement" xsi:type="string">container</item>
                    <item name="breakLine" xsi:type="boolean">false</item>
                    <item name="dataScope" xsi:type="string" />
                    <item name="label" xsi:type="string" />
                </item>
            </argument>
            <button name="assign_stores_button" template="ui/form/components/button/container">
                <settings>
                    <title translate="true">Assign Stores</title>
                    <dataScope />
                </settings>
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="formElement" xsi:type="string">container</item>
                        <item name="actions" xsi:type="array">
                            <item name="0" xsi:type="array">
                                <item name="targetName" xsi:type="string">${$.ns}.${$.ns}.assign_stores.assign_stores_modal</item>
                                <item name="actionName" xsi:type="string">toggleModal</item>
                            </item>
                        </item>
                        <item name="additionalForGroup" xsi:type="boolean">true</item>
                        <item name="additionalClasses" xsi:type="string">admin__field-medium</item>
                    </item>
                </argument>
            </button>
        </container>
        <dynamicRows name="assigned_stores" component="Magento_Ui/js/dynamic-rows/dynamic-rows-grid" sortOrder="20">
            <argument name="data" xsi:type="array">
                <item name="js_config" xsi:type="array">
                    <item name="dataProvider" xsi:type="string">data.sources.assign_stores_grid</item>
                    <item name="map" xsi:type="array">
                        <item name="Vendor_store_id" xsi:type="string">Vendor_store_id</item>
                        <item name="store_name" xsi:type="string">store_name</item>
                    </item>
                    <item name="identificationDRProperty" xsi:type="string">Vendor_store_id</item>
                </item>
            </argument>
            <settings>
                <label translate="true">Assigned Stores</label>
                <defaultRecord>false</defaultRecord>
                <addButton>false</addButton>
                <deleteProperty>true</deleteProperty>
                <recordTemplate>record</recordTemplate>
                <identificationProperty>Vendor_store_id</identificationProperty>
                <links>
                    <link name="insertData">${ $.provider }:${ $.dataProvider }</link>
                </links>
                <dndConfig>
                    <param name="enabled" xsi:type="boolean">true</param>
                    <param name="template" xsi:type="string">ui/dynamic-rows/cells/dnd</param>
                </dndConfig>
                <columnsHeader>true</columnsHeader>
            </settings>
            <container name="record" component="Magento_Ui/js/dynamic-rows/record">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="isTemplate" xsi:type="boolean">true</item>
                        <item name="is_collection" xsi:type="boolean">true</item>
                        <item name="dataScope" xsi:type="string" />
                        <item name="positionProvider" xsi:type="string">priority</item>
                    </item>
                </argument>
                <field name="Vendor_store_id" formElement="input" sortOrder="10">
                    <settings>
                        <elementTmpl>ui/dynamic-rows/cells/text</elementTmpl>
                        <dataType>text</dataType>
                        <dataScope>Vendor_store_id</dataScope>
                        <label translate="true">Store ID</label>
                        <labelVisible>false</labelVisible>
                    </settings>
                </field>
                <field name="store_name" formElement="input" sortOrder="20">
                    <settings>
                        <elementTmpl>ui/dynamic-rows/cells/text</elementTmpl>
                        <dataType>text</dataType>
                        <dataScope>store_name</dataScope>
                        <label translate="true">Store Name</label>
                        <labelVisible>false</labelVisible>
                    </settings>
                </field>
                <field name="priority" formElement="input" sortOrder="30">
                    <settings>
                        <elementTmpl>ui/form/element/input</elementTmpl>
                        <dataType>number</dataType>
                        <dataScope>priority</dataScope>
                        <label translate="true">Priority</label>
                        <visible>false</visible>
                    </settings>
                </field>
                <actionDelete name="actionDelete" template="Magento_InventoryCatalogAdminUi/stock/assign-sources/action-delete">
                    <argument name="data" xsi:type="array" />
                    <settings>
                        <label translate="true">Delete</label>
                        <elementTmpl>Magento_InventoryCatalogAdminUi/stock/assign-sources/action-delete</elementTmpl>
                        <dataType>text</dataType>
                        <componentType>actionDelete</componentType>
                    </settings>
                </actionDelete>
            </container>
        </dynamicRows>
        <modal name="assign_stores_modal">
            <settings>
                <options>
                    <option name="title" xsi:type="string" translate="true">Assign Stores</option>
                    <option 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="array">
                                    <item name="targetName" xsi:type="string">${ $.name }</item>
                                    <item name="actionName" xsi:type="string">actionCancel</item>
                                </item>
                            </item>
                        </item>
                        <item name="1" xsi:type="array">
                            <item name="text" xsi:type="string" translate="true">Done</item>
                            <item name="class" xsi:type="string">action-primary</item>
                            <item name="actions" xsi:type="array">
                                <item name="0" xsi:type="array">
                                    <item name="targetName" xsi:type="string">index = assign_stores_grid</item>
                                    <item name="actionName" xsi:type="string">save</item>
                                </item>
                                <item name="1" xsi:type="array">
                                    <item name="targetName" xsi:type="string">${ $.name }</item>
                                    <item name="actionName" xsi:type="string">actionDone</item>
                                </item>
                            </item>
                        </item>
                    </option>
                </options>
            </settings>
            <insertListing name="assign_stores_grid">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="cssclass" xsi:type="string">noclass</item>
                    </item>
                </argument>
                <settings>
                    <autoRender>true</autoRender>
                    <dataScope>assign_stores_grid</dataScope>
                    <ns>storepickup_index_listing</ns>
                    <externalProvider>storepickup_index_listing.storepickup_index_listing_data_source</externalProvider>
                    <selectionsProvider>storepickup_index_listing.storepickup_index_listing.spinner_columns.ids</selectionsProvider>
                    <dataLinks>
                        <imports>false</imports>
                        <exports>true</exports>
                    </dataLinks>
                    <externalFilterMode>true</externalFilterMode>
                </settings>
            </insertListing>
        </modal>
    </fieldset>
</form>

I've also implemented another way using the custom grid

Custom Grid for store selection

but this has some deprecated method and mostly,i wanted to reuse the listing grid which I've created so any help on this would be highly appreciated

2

0

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.