Question

What is the Difference way to use of Block and ui_components to Make the Admin side grid and form and fields and elements in the form, can someone explain, which is better way to choose and Why ?

Was it helpful?

Solution

There are many differences to create Admin Side grid using UI Component and Block

Both are having their own Pros and Cons mentioned below

UI Component:

Pros:

  1. Creating Admin grid using UI component use less code

  2. It can easily be extended with just another XML file in a different module (If you want to extend Magento core grid you can easily add new fields)

  3. It uses less code than Block because it is mostly configuration

  4. You get a cool grid with show/hide columns, full text search, inline edit, export built in and maybe others. (It is easy to implement these features using Bookmark tag in uicomponent file)

  5. You can easily filter grid collection using filter tag.

Cons:

  1. It is difficult to debug if any issue occurs.
  2. It is difficult to modify.
  3. Difficult to build non-standard grids.
  4. It doesn't have very much control over what happens.

Blocks:

Pros:

  1. It is easy to debug.
  2. Easy to build non-standard grids.
  3. You got full control of what happens.
  4. It is easy to build grids using multiple collections

Cons:

  1. you need to write the same code over and over again.
  2. Grid is not that flexible or extensible.

Conclusion: UI component is better to use instead of block method. Because of its less code and it is easy to extend Magento core grids to add new columns. Magento creates many prebuild tags which makes UI component easy to apply features like (filter, show/hide columns from grid, search and many more options)

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top