0

I have created a UI component to represent the data in my custom eav model. But it didn't work at all. The spinning animation didn't disappear and my page looks like this

enter image description here

I checked all the log file and it didn't have any php error. I checked console tab in my browser too and it didn't have any javascript error.

This is my entity table enter image description here

This is my ui component code

<?xml version="1.0" ?>
<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">vendor_vendor_index.vendor_grid_data_source</item>
 <item name="deps" xsi:type="string">vendor_vendor_index.vendor_grid_data_source</item>
 </item>
 <item name="spinner" xsi:type="string">vendor_vendor_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" translate="true" xsi:type="string">Add new Vendor</item>
 <item name="class" xsi:type="string">primary</item>
 <item name="url" xsi:type="string">*/*/new</item>
 </item>
 </item>
 </argument>
 <dataSource name="vendor_grid_data_source">
 <argument name="dataProvider" xsi:type="configurableObject">
 <argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
 <argument name="name" xsi:type="string">vendor_grid_data_source</argument>
 <argument name="primaryFieldName" xsi:type="string">entity_id</argument>
 <argument name="requestFieldName" xsi:type="string">entity_id</argument>
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="update_url" path="mui/index/render" xsi:type="url"/>
 </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/grid/provider</item>
 </item>
 </argument>
 </dataSource>
 <columns name="vendor_vendor_columns">
 <selectionsColumn name="ids">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="indexField" xsi:type="string">entity_id</item>
 </item>
 </argument>
 </selectionsColumn>
 <column name="entity_id">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="sortOrder" xsi:type="number">10</item>
 <item name="filter" xsi:type="string">text</item>
 <item name="sorting" xsi:type="string">asc</item>
 <item name="label" translate="true" xsi:type="string">ID</item>
 <item name="dataType" xsi:type="string">text</item>
 </item>
 </argument>
 </column>
 </columns>
</listing>

This is my di.xml

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
 <virtualType name="{Namespace}\{ModuleName}\Model\ResourceModel\Vendor\Grid\Collection"
 type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
 <arguments>
 <argument name="mainTable" xsi:type="string">namespace_vendor_entity</argument>
 <argument name="resourceModel" xsi:type="string">{Namespace}\{ModuleName}\Model\ResourceModel\Vendor\Collection</argument>
 </arguments>
 </virtualType>
 <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
 <arguments>
 <argument name="collections" xsi:type="array">
 <item name="vendor_grid_data_source" xsi:type="string">{Namespace}\{ModuleName}\Model\ResourceModel\Vendor\Grid\Collection</item>
 </argument>
 </arguments>
 </type>
</config>

This is my layout code. The ui component file name is vendor_listing.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
 <update handle="formkey"/>
 <body>
 <referenceContainer name="content">
 <uiComponent name="vendor_listing"/>
 </referenceContainer>
 </body>
</page>

Please tell me why it's not working and how can I debug this?

asked Jul 17, 2018 at 10:27

1 Answer 1

0

Please make path to resourcemodel instead of collection:

write {Namespace}{ModuleName}\Model\ResourceModel\Vendor instead of {Namespace}{ModuleName}\Model\ResourceModel\Vendor\Collection

 <?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="{Namespace}\{ModuleName}\Model\ResourceModel\Vendor\Grid\Collection"
 type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
 <arguments>
 <argument name="mainTable" xsi:type="string">namespace_vendor_entity</argument>
 <argument name="resourceModel" xsi:type="string">{Namespace}\{ModuleName}\Model\ResourceModel\Vendor</argument>
 </arguments>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
 <arguments>
 <argument name="collections" xsi:type="array">
 <item name="vendor_grid_data_source" xsi:type="string">{Namespace}\{ModuleName}\Model\ResourceModel\Vendor\Grid\Collection</item>
 </argument>
 </arguments>
</type>
answered Jul 17, 2018 at 10:58
9
  • it didn't work after I changed it to {Namespace}{ModuleName}\Model\ResourceModel\Vendor Commented Jul 17, 2018 at 11:43
  • Have you check after clearing cache and cookie or after removing generated folder? Commented Jul 17, 2018 at 11:47
  • Yes. I run the command setup:upgrade, cache:flus and cache:clean but it's still the same Commented Jul 17, 2018 at 11:54
  • @thanhdv2811 Can you please post your layout file code here Commented Jul 17, 2018 at 11:59
  • 1
    you have to replace vendor_vendor_index.vendor_grid_data_source with vendor_listing.vendor_grid_data_source Commented Jul 19, 2018 at 5:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.