2

In Magento 2 ui_component xml files are used to show grid/forms in admin. The model collection which will be used by the grid will be configured in di.xml as mentioned here

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="sample_demolist_listing_data_source" xsi:type="string">Genmato\Sample\Model\ResourceModel\Demo\Grid\Collection</item>
            </argument>
        </arguments>
    </type>

Now in the ui_component xml file arguments will be mentioned as below

<argument name="data" xsi:type="array">
    <item name="js_config" xsi:type="array">
        <item name="provider" xsi:type="string">sample_demolist_listing.sample_demolist_listing_data_source</item>
        <item name="deps" xsi:type="string">sample_demolist_listing.sample_demolist_listing_data_source</item>
    </item>
 <item name="spinner" xsi:type="string">sample_demolist_columns</item>
    <item name="buttons" xsi:type="array">
        <item name="add" xsi:type="array">
            <item name="name" xsi:type="string">add</item>
            <item name="label" xsi:type="string" translate="true">Add New Item</item>
            <item name="class" xsi:type="string">primary</item>
            <item name="url" xsi:type="string">*/*/new</item>
        </item>
    </item>
</argument>

1. What does <argument name="data" xsi:type="array"> do?
2. What is the usages of tags js_config, provider, deps, spinner, class, url ?
If I can get some reference links/tutorials which explains all these tags will be much more helpful.

1

First look in di.xml

\Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory

class define one object $collections

public function __construct(
    ObjectManagerInterface $objectManagerInterface,
    array $collections = []
) {
    $this->collections = $collections;  <==== Injection in consturctor
    $this->objectManager = $objectManagerInterface;
}

How magento can get this value

\Magento\Framework\View\Element\UiComponentFactory::create()

This method will get all arugments data in argument node

  • That helps. Can you share some thoughts on question 2? – amitshree Jan 16 '16 at 11:13
  • In magento 2 core team have created some Collector, Converter. It used to collect all data from your xml. All of them will be merge and spit to array for each attributes You can see more in \Framework\View\Element\UiComponent\Config\ folder Magento\module-ui\Model\Manager.php::prepareData() – mrtuvn Jan 16 '16 at 13:38
  • Hi Mrtuvn , i need suggestion on this error as to how to debug this: magento.stackexchange.com/questions/161957/… – Sushivam Feb 28 '17 at 8:35

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.