I want to create an admin grid.
Taking the reference to https://www.mageplaza.com/magento-2-module-development/create-admin-grid-magento-2.html, I can see there are following two ways :
- Using Component
- Using Layout
My question here is which one is better and why?
1 Answer 1
Each approach has upsides and downsides.
I suggest using the ui-components one because this is where Magento 2 is going right now.
The layouts and blocks approach is just legacy from the M1 version.
But let's take them separately:
Ui Components
- (+) It's mostly configuration. So you write less code, so less code that can break
- (+) you get a cool grid with show/hide columns, full text search, inline edit, export built in and maybe others.
- (+) It can easily be extended with just another xml file in a different module
- (+) any new feature magento rolls out for the grids you will get it automatically in your grid.
- (-) Difficult to debug
- (-) Difficult to build non standard grids
- (-) Not very much control over what happens
Layout files and blocks:
- (+) You got full control of what happens.
- (+) Relatively easy to build non-standard grids.
- (+) Easy to debug
- (+) You can use your knowledge from M1 to do it.
- (-) Grid is not that flexible or extensible.
- (-) you need to write the same code over and over again.
- (-) More code to test or that can break
That's all I have so far. The lists are far from being complete.
-
Can we develop specific records export csv functionality via layout grid in M2? Like this: prnt.sc/1xdrekrYogita– Yogita2021年10月26日 13:33:01 +00:00Commented Oct 26, 2021 at 13:33