2

I'm trying to use one grid for multiple ResourceModels, so far I've got one grid working fine.

I can load the grid up fine using http:{}/admin/grid/grid/ enter image description here

However when i create a new route to load the same controller: http:{}/admin/grid2/grid/ . I get no main block content enter image description here

enter image description here

Here's my component UI based grid setup: Works fine for route /admin/grid/grid.

enter image description here

Does anyone know if i need to duplicate some files/directories to get grid2 to show?

1

You need to create grid2_grid_index.xml file under layout same as grid_grid_index.xml

2

You have to copy only layout file, due to 'grid2' route already mentioned in routes.xml.

You need to create only grid2_grid_index.xml.
copy grid_grid_index.xml to grid2_grid_index.xml you can call same ui_component file in that layout.xml file.

  • 1
    Thank you for the answer! I didn't need to copy the controller to make the grid show, is there some other functionality that needs a copied controller file? Controller/Adminhtml/Grid/Index.php sets the title via resultFactoy->getConfig()->getTitle()->prepend('Grid List'), Http://{}/admin/grid2/grid has "Grid List" Title – Pathfinder Jan 11 at 5:57
  • 1
    then how your layout file called which grid2_grid_index.xml ? – Himanshu Jan 11 at 6:01
  • I know UI-Component is loaded this way, but Grid2_grid_index.xml must be built in... Di.xml -> <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory"> <arguments> <argument name="collections" xsi:type="array"> <item name="grid_record_grid_list_data_source" xsi:type="string"> – Pathfinder Jan 11 at 6:03
  • 1
    This code is for loading data collection – Himanshu Jan 11 at 6:04
  • 1
    Oh I got it you have created two routes . so you don't need to create controller file !! yes it will be worked cheers +1 – Himanshu Jan 11 at 6:08

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.