Magento 2 : Display multiple grids in admin area












0















I have displayed my one custom table in a grid format. Now, I want to display one other custom table in a grid format (Under different menu). But I am little bit confused, how to add code in di.xml file



Here is my di.xml which I have created for my first grid :

app/code/Ved/Mymodule/etc/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="VedMymoduleModelResourceModelNewsCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">ved_zipcodes</argument> <!-- here ved_zipcodes this is the db table name -->
<argument name="resourceModel" xsi:type="string">VedMymoduleModelResourceModelNews</argument> <!-- Path -->
</arguments>
</virtualType>
<type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<!-- Here name value, we will use in mymodule_my_grid.xml layout file -->
<item name="mymodule_news_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelNewsCollection</item> <!-- Collection path -->
</argument>
</arguments>
</type>
</config>





How should I update my di.xml for displaying second grid in admin using the same custom module?



Any help would be highly appreciated. Thank you.










share|improve this question
















bumped to the homepage by Community 24 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • did you got any solution?

    – Piyush
    Jun 7 '17 at 13:18











  • No, I did not get. Let me know if you find anything.

    – vedu
    Jun 8 '17 at 5:15
















0















I have displayed my one custom table in a grid format. Now, I want to display one other custom table in a grid format (Under different menu). But I am little bit confused, how to add code in di.xml file



Here is my di.xml which I have created for my first grid :

app/code/Ved/Mymodule/etc/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="VedMymoduleModelResourceModelNewsCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">ved_zipcodes</argument> <!-- here ved_zipcodes this is the db table name -->
<argument name="resourceModel" xsi:type="string">VedMymoduleModelResourceModelNews</argument> <!-- Path -->
</arguments>
</virtualType>
<type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<!-- Here name value, we will use in mymodule_my_grid.xml layout file -->
<item name="mymodule_news_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelNewsCollection</item> <!-- Collection path -->
</argument>
</arguments>
</type>
</config>





How should I update my di.xml for displaying second grid in admin using the same custom module?



Any help would be highly appreciated. Thank you.










share|improve this question
















bumped to the homepage by Community 24 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • did you got any solution?

    – Piyush
    Jun 7 '17 at 13:18











  • No, I did not get. Let me know if you find anything.

    – vedu
    Jun 8 '17 at 5:15














0












0








0








I have displayed my one custom table in a grid format. Now, I want to display one other custom table in a grid format (Under different menu). But I am little bit confused, how to add code in di.xml file



Here is my di.xml which I have created for my first grid :

app/code/Ved/Mymodule/etc/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="VedMymoduleModelResourceModelNewsCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">ved_zipcodes</argument> <!-- here ved_zipcodes this is the db table name -->
<argument name="resourceModel" xsi:type="string">VedMymoduleModelResourceModelNews</argument> <!-- Path -->
</arguments>
</virtualType>
<type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<!-- Here name value, we will use in mymodule_my_grid.xml layout file -->
<item name="mymodule_news_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelNewsCollection</item> <!-- Collection path -->
</argument>
</arguments>
</type>
</config>





How should I update my di.xml for displaying second grid in admin using the same custom module?



Any help would be highly appreciated. Thank you.










share|improve this question
















I have displayed my one custom table in a grid format. Now, I want to display one other custom table in a grid format (Under different menu). But I am little bit confused, how to add code in di.xml file



Here is my di.xml which I have created for my first grid :

app/code/Ved/Mymodule/etc/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="VedMymoduleModelResourceModelNewsCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">ved_zipcodes</argument> <!-- here ved_zipcodes this is the db table name -->
<argument name="resourceModel" xsi:type="string">VedMymoduleModelResourceModelNews</argument> <!-- Path -->
</arguments>
</virtualType>
<type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<!-- Here name value, we will use in mymodule_my_grid.xml layout file -->
<item name="mymodule_news_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelNewsCollection</item> <!-- Collection path -->
</argument>
</arguments>
</type>
</config>





How should I update my di.xml for displaying second grid in admin using the same custom module?



Any help would be highly appreciated. Thank you.







module grid magento2.1.0 di.xml






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 12 '16 at 4:38







vedu

















asked Aug 11 '16 at 10:08









veduvedu

38711032




38711032





bumped to the homepage by Community 24 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 24 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • did you got any solution?

    – Piyush
    Jun 7 '17 at 13:18











  • No, I did not get. Let me know if you find anything.

    – vedu
    Jun 8 '17 at 5:15



















  • did you got any solution?

    – Piyush
    Jun 7 '17 at 13:18











  • No, I did not get. Let me know if you find anything.

    – vedu
    Jun 8 '17 at 5:15

















did you got any solution?

– Piyush
Jun 7 '17 at 13:18





did you got any solution?

– Piyush
Jun 7 '17 at 13:18













No, I did not get. Let me know if you find anything.

– vedu
Jun 8 '17 at 5:15





No, I did not get. Let me know if you find anything.

– vedu
Jun 8 '17 at 5:15










1 Answer
1






active

oldest

votes


















0














To add second grid in same module you have to add collection data of second grid as second item of CollectionFactory node's collections argument.
So in your case CollectionFactory will look like this -



<type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<!-- Here name value, we will use in mymodule_my_grid.xml layout file -->
<item name="mymodule_news_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelNewsCollection</item> <!-- Collection path -->
<item name="mymodule_secondmodel_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelSecondModelCollection</item> <!-- Collection path added for second grid -->
</argument>
</arguments>
</type>


The other nodes in the di.xml can be repeated for the second grid with change in unique_name for nodes (e.g - FilterPool, DataProvider, SerarchResult nodes) ,listing_file_name, Collection and ResourceModel path respectively different for each grid.



Here is the example of my di.xml having two grid -



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

<!-- This nodes below are for first grid -->
<virtualType name="firstGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here firstGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
<arguments>
<argument name="appliers" xsi:type="array">
<item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
<item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
</argument>
</arguments>
</virtualType>
<virtualType name="FirstGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here FirstGridDataProvider is unique name for Dataprovider node -->
<arguments>
<argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelFirstGridModelCollection</argument>
<argument name="filterPool" xsi:type="object" shared="false">firstGridFilterPool</argument>
</arguments>
</virtualType>
<type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="first_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModelGridCollection</item> <!-- Add Collection data for First Grid -->
<item name="second_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModelGridCollection</item> <!-- Add Collection data for Second Grid -->
</argument>
</arguments>
</type>
<virtualType name="NamespaceModulenameModelResourceModelFirstGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">first_grid_tablename</argument>
<argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModel</argument>
</arguments>
</virtualType>

<!-- This nodes below are repeated for Second grid -->
<virtualType name="SecondGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here SecondGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
<arguments>
<argument name="appliers" xsi:type="array">
<item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
<item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
</argument>
</arguments>
</virtualType>
<virtualType name="SecondGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here SecondGridDataProvider is unique name for Dataprovider node -->
<arguments>
<argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelSecondGridModelCollection</argument>
<argument name="filterPool" xsi:type="object" shared="false">SecondGridFilterPool</argument>
</arguments>
</virtualType>

<virtualType name="NamespaceModulenameModelResourceModelSecondGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">second_grid_tablename</argument>
<argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModel</argument>
</arguments>
</virtualType>
</config>


Hope it will help you.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f130992%2fmagento-2-display-multiple-grids-in-admin-area%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    To add second grid in same module you have to add collection data of second grid as second item of CollectionFactory node's collections argument.
    So in your case CollectionFactory will look like this -



    <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
    <arguments>
    <argument name="collections" xsi:type="array">
    <!-- Here name value, we will use in mymodule_my_grid.xml layout file -->
    <item name="mymodule_news_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelNewsCollection</item> <!-- Collection path -->
    <item name="mymodule_secondmodel_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelSecondModelCollection</item> <!-- Collection path added for second grid -->
    </argument>
    </arguments>
    </type>


    The other nodes in the di.xml can be repeated for the second grid with change in unique_name for nodes (e.g - FilterPool, DataProvider, SerarchResult nodes) ,listing_file_name, Collection and ResourceModel path respectively different for each grid.



    Here is the example of my di.xml having two grid -



    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

    <!-- This nodes below are for first grid -->
    <virtualType name="firstGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here firstGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
    <arguments>
    <argument name="appliers" xsi:type="array">
    <item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
    <item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
    </argument>
    </arguments>
    </virtualType>
    <virtualType name="FirstGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here FirstGridDataProvider is unique name for Dataprovider node -->
    <arguments>
    <argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelFirstGridModelCollection</argument>
    <argument name="filterPool" xsi:type="object" shared="false">firstGridFilterPool</argument>
    </arguments>
    </virtualType>
    <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
    <arguments>
    <argument name="collections" xsi:type="array">
    <item name="first_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModelGridCollection</item> <!-- Add Collection data for First Grid -->
    <item name="second_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModelGridCollection</item> <!-- Add Collection data for Second Grid -->
    </argument>
    </arguments>
    </type>
    <virtualType name="NamespaceModulenameModelResourceModelFirstGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
    <arguments>
    <argument name="mainTable" xsi:type="string">first_grid_tablename</argument>
    <argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModel</argument>
    </arguments>
    </virtualType>

    <!-- This nodes below are repeated for Second grid -->
    <virtualType name="SecondGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here SecondGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
    <arguments>
    <argument name="appliers" xsi:type="array">
    <item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
    <item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
    </argument>
    </arguments>
    </virtualType>
    <virtualType name="SecondGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here SecondGridDataProvider is unique name for Dataprovider node -->
    <arguments>
    <argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelSecondGridModelCollection</argument>
    <argument name="filterPool" xsi:type="object" shared="false">SecondGridFilterPool</argument>
    </arguments>
    </virtualType>

    <virtualType name="NamespaceModulenameModelResourceModelSecondGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
    <arguments>
    <argument name="mainTable" xsi:type="string">second_grid_tablename</argument>
    <argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModel</argument>
    </arguments>
    </virtualType>
    </config>


    Hope it will help you.






    share|improve this answer




























      0














      To add second grid in same module you have to add collection data of second grid as second item of CollectionFactory node's collections argument.
      So in your case CollectionFactory will look like this -



      <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
      <arguments>
      <argument name="collections" xsi:type="array">
      <!-- Here name value, we will use in mymodule_my_grid.xml layout file -->
      <item name="mymodule_news_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelNewsCollection</item> <!-- Collection path -->
      <item name="mymodule_secondmodel_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelSecondModelCollection</item> <!-- Collection path added for second grid -->
      </argument>
      </arguments>
      </type>


      The other nodes in the di.xml can be repeated for the second grid with change in unique_name for nodes (e.g - FilterPool, DataProvider, SerarchResult nodes) ,listing_file_name, Collection and ResourceModel path respectively different for each grid.



      Here is the example of my di.xml having two grid -



      <?xml version="1.0"?>
      <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

      <!-- This nodes below are for first grid -->
      <virtualType name="firstGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here firstGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
      <arguments>
      <argument name="appliers" xsi:type="array">
      <item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
      <item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
      </argument>
      </arguments>
      </virtualType>
      <virtualType name="FirstGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here FirstGridDataProvider is unique name for Dataprovider node -->
      <arguments>
      <argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelFirstGridModelCollection</argument>
      <argument name="filterPool" xsi:type="object" shared="false">firstGridFilterPool</argument>
      </arguments>
      </virtualType>
      <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
      <arguments>
      <argument name="collections" xsi:type="array">
      <item name="first_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModelGridCollection</item> <!-- Add Collection data for First Grid -->
      <item name="second_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModelGridCollection</item> <!-- Add Collection data for Second Grid -->
      </argument>
      </arguments>
      </type>
      <virtualType name="NamespaceModulenameModelResourceModelFirstGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
      <arguments>
      <argument name="mainTable" xsi:type="string">first_grid_tablename</argument>
      <argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModel</argument>
      </arguments>
      </virtualType>

      <!-- This nodes below are repeated for Second grid -->
      <virtualType name="SecondGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here SecondGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
      <arguments>
      <argument name="appliers" xsi:type="array">
      <item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
      <item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
      </argument>
      </arguments>
      </virtualType>
      <virtualType name="SecondGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here SecondGridDataProvider is unique name for Dataprovider node -->
      <arguments>
      <argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelSecondGridModelCollection</argument>
      <argument name="filterPool" xsi:type="object" shared="false">SecondGridFilterPool</argument>
      </arguments>
      </virtualType>

      <virtualType name="NamespaceModulenameModelResourceModelSecondGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
      <arguments>
      <argument name="mainTable" xsi:type="string">second_grid_tablename</argument>
      <argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModel</argument>
      </arguments>
      </virtualType>
      </config>


      Hope it will help you.






      share|improve this answer


























        0












        0








        0







        To add second grid in same module you have to add collection data of second grid as second item of CollectionFactory node's collections argument.
        So in your case CollectionFactory will look like this -



        <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
        <arguments>
        <argument name="collections" xsi:type="array">
        <!-- Here name value, we will use in mymodule_my_grid.xml layout file -->
        <item name="mymodule_news_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelNewsCollection</item> <!-- Collection path -->
        <item name="mymodule_secondmodel_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelSecondModelCollection</item> <!-- Collection path added for second grid -->
        </argument>
        </arguments>
        </type>


        The other nodes in the di.xml can be repeated for the second grid with change in unique_name for nodes (e.g - FilterPool, DataProvider, SerarchResult nodes) ,listing_file_name, Collection and ResourceModel path respectively different for each grid.



        Here is the example of my di.xml having two grid -



        <?xml version="1.0"?>
        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

        <!-- This nodes below are for first grid -->
        <virtualType name="firstGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here firstGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
        <arguments>
        <argument name="appliers" xsi:type="array">
        <item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
        <item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
        </argument>
        </arguments>
        </virtualType>
        <virtualType name="FirstGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here FirstGridDataProvider is unique name for Dataprovider node -->
        <arguments>
        <argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelFirstGridModelCollection</argument>
        <argument name="filterPool" xsi:type="object" shared="false">firstGridFilterPool</argument>
        </arguments>
        </virtualType>
        <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
        <arguments>
        <argument name="collections" xsi:type="array">
        <item name="first_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModelGridCollection</item> <!-- Add Collection data for First Grid -->
        <item name="second_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModelGridCollection</item> <!-- Add Collection data for Second Grid -->
        </argument>
        </arguments>
        </type>
        <virtualType name="NamespaceModulenameModelResourceModelFirstGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
        <arguments>
        <argument name="mainTable" xsi:type="string">first_grid_tablename</argument>
        <argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModel</argument>
        </arguments>
        </virtualType>

        <!-- This nodes below are repeated for Second grid -->
        <virtualType name="SecondGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here SecondGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
        <arguments>
        <argument name="appliers" xsi:type="array">
        <item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
        <item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
        </argument>
        </arguments>
        </virtualType>
        <virtualType name="SecondGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here SecondGridDataProvider is unique name for Dataprovider node -->
        <arguments>
        <argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelSecondGridModelCollection</argument>
        <argument name="filterPool" xsi:type="object" shared="false">SecondGridFilterPool</argument>
        </arguments>
        </virtualType>

        <virtualType name="NamespaceModulenameModelResourceModelSecondGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
        <arguments>
        <argument name="mainTable" xsi:type="string">second_grid_tablename</argument>
        <argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModel</argument>
        </arguments>
        </virtualType>
        </config>


        Hope it will help you.






        share|improve this answer













        To add second grid in same module you have to add collection data of second grid as second item of CollectionFactory node's collections argument.
        So in your case CollectionFactory will look like this -



        <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
        <arguments>
        <argument name="collections" xsi:type="array">
        <!-- Here name value, we will use in mymodule_my_grid.xml layout file -->
        <item name="mymodule_news_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelNewsCollection</item> <!-- Collection path -->
        <item name="mymodule_secondmodel_grid_data_source" xsi:type="string">VedMymoduleModelResourceModelSecondModelCollection</item> <!-- Collection path added for second grid -->
        </argument>
        </arguments>
        </type>


        The other nodes in the di.xml can be repeated for the second grid with change in unique_name for nodes (e.g - FilterPool, DataProvider, SerarchResult nodes) ,listing_file_name, Collection and ResourceModel path respectively different for each grid.



        Here is the example of my di.xml having two grid -



        <?xml version="1.0"?>
        <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

        <!-- This nodes below are for first grid -->
        <virtualType name="firstGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here firstGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
        <arguments>
        <argument name="appliers" xsi:type="array">
        <item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
        <item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
        </argument>
        </arguments>
        </virtualType>
        <virtualType name="FirstGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here FirstGridDataProvider is unique name for Dataprovider node -->
        <arguments>
        <argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelFirstGridModelCollection</argument>
        <argument name="filterPool" xsi:type="object" shared="false">firstGridFilterPool</argument>
        </arguments>
        </virtualType>
        <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
        <arguments>
        <argument name="collections" xsi:type="array">
        <item name="first_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModelGridCollection</item> <!-- Add Collection data for First Grid -->
        <item name="second_grid_data_source" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModelGridCollection</item> <!-- Add Collection data for Second Grid -->
        </argument>
        </arguments>
        </type>
        <virtualType name="NamespaceModulenameModelResourceModelFirstGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
        <arguments>
        <argument name="mainTable" xsi:type="string">first_grid_tablename</argument>
        <argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelFirstGridModel</argument>
        </arguments>
        </virtualType>

        <!-- This nodes below are repeated for Second grid -->
        <virtualType name="SecondGridFilterPool" type="MagentoFrameworkViewElementUiComponentDataProviderFilterPool"> <!-- here SecondGridFilterPool is unique name for filterpool node and it is later user as Dataprovider node's filerPool argument's value -->
        <arguments>
        <argument name="appliers" xsi:type="array">
        <item name="regular" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderRegularFilter</item>
        <item name="fulltext" xsi:type="object">MagentoFrameworkViewElementUiComponentDataProviderFulltextFilter</item>
        </argument>
        </arguments>
        </virtualType>
        <virtualType name="SecondGridDataProvider" type="MagentoFrameworkViewElementUiComponentDataProviderDataProvider"> <!-- here SecondGridDataProvider is unique name for Dataprovider node -->
        <arguments>
        <argument name="collection" xsi:type="object" shared="false">NamespaceModulenameModelResourceModelSecondGridModelCollection</argument>
        <argument name="filterPool" xsi:type="object" shared="false">SecondGridFilterPool</argument>
        </arguments>
        </virtualType>

        <virtualType name="NamespaceModulenameModelResourceModelSecondGridModelGridCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
        <arguments>
        <argument name="mainTable" xsi:type="string">second_grid_tablename</argument>
        <argument name="resourceModel" xsi:type="string">NamespaceModulenameModelResourceModelSecondGridModel</argument>
        </arguments>
        </virtualType>
        </config>


        Hope it will help you.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 8 '17 at 14:34









        PiyushPiyush

        4,80972053




        4,80972053






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f130992%2fmagento-2-display-multiple-grids-in-admin-area%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            What other Star Trek series did the main TNG cast show up in?

            Berlina muro

            Berlina aerponto