3

load product grid ui component

Am following this code its work fine and showing product grid in UI-component form but how can i post data from listing to controller with other fields in the form...

My code for successpage_page_form.xml in

Namespace/Module/view/adminhtml/ui_component/successpage_page_form.xml

<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">successpage_page_form.successpage_page_form_data_source</item>
        <item name="deps" xsi:type="string">successpage_page_form.successpage_page_form_data_source</item>
    </item>
    <item name="label" xsi:type="string" translate="true">Layout Information</item>
    <item name="config" xsi:type="array">
        <item name="dataScope" xsi:type="string">data</item>
        <item name="namespace" xsi:type="string">successpage_page_form</item>
    </item>
    <item name="layout" xsi:type="array">
        <item name="type" xsi:type="string">tabs</item>
        <item name="navContainerName" xsi:type="string">left</item>
    </item>
</argument>
<dataSource name="successpage_page_form_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
        <argument name="class" xsi:type="string">Namespace\Module\Model\DataProvider</argument>
        <argument name="name" xsi:type="string">successpage_page_form_data_source</argument>
        <argument name="primaryFieldName" xsi:type="string">layout_id</argument>
        <argument name="requestFieldName" xsi:type="string">layout_id</argument>
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="submit_url" xsi:type="url" path="successpage/page/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="layout_details">
    <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">Layout Details</item>
            <item name="sortOrder" xsi:type="number">20</item>
        </item>
    </argument>
    <field name="layout_id">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="visible" xsi:type="boolean">false</item>
                <item name="dataType" xsi:type="string">text</item>
                <item name="label" xsi:type="string" translate="true">Layout Id</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">data</item>
                <item name="dataScope" xsi:type="string">layout_id</item>
            </item>
        </argument>
    </field>
    <field name="template_id">
        <argument name="data" xsi:type="array">
            <item name="options" xsi:type="object">FME\SuccessPage\Model\Config\Source\Options</item>
            <item name="config" xsi:type="array">
                <item name="label" xsi:type="string" translate="true">Layout</item>
                <item name="visible" xsi:type="boolean">true</item>
                <item name="dataType" xsi:type="string">number</item>
                <item name="formElement" xsi:type="string">select</item>
                <item name="source" xsi:type="string">data</item>
                <item name="dataScope" xsi:type="string">template_id</item>
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                </item>
            </item>
        </argument>
    </field>
    <field name="template_name">
        <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">Layout Name</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">data</item>
                <item name="dataScope" xsi:type="string">template_name</item>
            </item>
        </argument>
    </field>
    <field name="template_priority">
        <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">Layout Priority</item>
                <item name="formElement" xsi:type="string">input</item>
                <item name="source" xsi:type="string">data</item>
                <item name="dataScope" xsi:type="string">template_priority</item>
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                </item>
            </item>
        </argument>
    </field>
</fieldset>
<fieldset name="assign_products">
    <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">Select Products</item>
            <item name="sortOrder" xsi:type="number">21</item>
        </item>
    </argument>
    <insertListing>
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="autoRender" xsi:type="boolean">true</item>
                <item name="ns" xsi:type="string">successpage_productgrid_listing</item>
            </item>
        </argument>
    </insertListing>
</fieldset>

My code for successpage_productgrid_listing.xml in

Namespace/Module/view/adminhtml/ui_component/successpage_productgrid_listing.xml

<listing 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">successpage_productgrid_listing.successpage_productgrid_listing_data_source</item>
    </item>
</argument>
<settings>
    <spinner>product_columns</spinner>
    <deps>
        <dep>successpage_productgrid_listing.successpage_productgrid_listing_data_source</dep>
    </deps>
</settings>
<dataSource name="successpage_productgrid_listing_data_source" component="Magento_Ui/js/grid/provider">
    <settings>
        <storageConfig>
            <param name="dataScope" xsi:type="string">filters.store_id</param>
        </storageConfig>
        <updateUrl path="mui/index/render"/>
    </settings>
    <aclResource>Magento_Catalog::products</aclResource>
    <dataProvider class="Magento\Catalog\Ui\DataProvider\Product\ProductDataProvider" name="successpage_productgrid_listing_data_source">
        <settings>
            <requestFieldName>id</requestFieldName>
            <primaryFieldName>entity_id</primaryFieldName>
        </settings>
    </dataProvider>
</dataSource>
<listingToolbar name="listing_top">
    <settings>
        <sticky>false</sticky>
    </settings>
    <bookmark name="bookmarks"/>
    <columnsControls name="columns_controls"/>
    <filters name="listing_filters">
        <filterSelect name="store_id" provider="${ $.parentName }">
            <settings>
                <options class="Magento\Store\Ui\Component\Listing\Column\Store\Options"/>
                <caption translate="true">All Store Views</caption>
                <label translate="true">Store View</label>
                <dataScope>store_id</dataScope>
            </settings>
        </filterSelect>
    </filters>
    <paging name="listing_paging"/>
</listingToolbar>
<columns name="product_columns" class="Magento\Catalog\Ui\Component\Listing\Columns">
    <settings>
        <childDefaults>
            <param name="fieldAction" xsi:type="array">
                <item name="provider" xsi:type="string">successpage_productgrid_listing.successpage_productgrid_listing.product_columns.actions</item>
                <item name="target" xsi:type="string">applyAction</item>
                <item name="params" xsi:type="array">
                    <item name="0" xsi:type="string">edit</item>
                    <item name="1" xsi:type="string">${ $.$data.rowIndex }</item>
                </item>
            </param>
        </childDefaults>
    </settings>
    <selectionsColumn name="ids" sortOrder="0">
        <settings>
            <indexField>entity_id</indexField>
        </settings>
    </selectionsColumn>
    <column name="entity_id" sortOrder="10">
        <settings>
            <filter>textRange</filter>
            <label translate="true">ID</label>
            <sorting>asc</sorting>
        </settings>
    </column>
    <column name="thumbnail" class="Magento\Catalog\Ui\Component\Listing\Columns\Thumbnail" component="Magento_Ui/js/grid/columns/thumbnail" sortOrder="20">
        <settings>
            <altField>name</altField>
            <hasPreview>1</hasPreview>
            <addField>true</addField>
            <label translate="true">Thumbnail</label>
            <sortable>false</sortable>
        </settings>
    </column>
    <column name="name" sortOrder="30">
        <settings>
            <addField>true</addField>
            <filter>text</filter>
            <label translate="true">Name</label>
        </settings>
    </column>
    <column name="type_id" component="Magento_Ui/js/grid/columns/select" sortOrder="40">
        <settings>
            <options class="Magento\Catalog\Model\Product\Type"/>
            <filter>select</filter>
            <dataType>select</dataType>
            <label translate="true">Type</label>
        </settings>
    </column>
    <column name="price" class="Magento\Catalog\Ui\Component\Listing\Columns\Price" sortOrder="70">
        <settings>
            <addField>true</addField>
            <filter>textRange</filter>
            <label translate="true">Price</label>
        </settings>
    </column>
    <column name="status" component="Magento_Ui/js/grid/columns/select" sortOrder="90">
        <settings>
            <addField>true</addField>
            <options class="Magento\Catalog\Model\Product\Attribute\Source\Status"/>
            <filter>select</filter>
            <dataType>select</dataType>
            <label translate="true">Status</label>
        </settings>
    </column>
    <actionsColumn name="actions" class="Magento\Catalog\Ui\Component\Listing\Columns\ProductActions" sortOrder="200">
        <settings>
            <indexField>entity_id</indexField>
        </settings>
    </actionsColumn>
</columns>

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.