How to Create Custom Admin Grid

Blog
Spread the love

In this blog we will learn how to create custom admin grid. Magento 2 grids are a way to list the items in a database table for better management. Grid allows us to sort, filter, edit and update data.

Before you begin: You should have a custom module, in that you need to create menu and other related files and folders.

If you want to create custom menu click here.

To register a frontend route, we must create a routes.xml file:

Step 1: Create routes.xml

app/code/Bluethink/CustomMenu/etc/adminhtml/routes.xml

The id attribute is a unique string which will identify this route.

The frontName attribute is also a unique string which will be shown on the url request.

Step 2: Create controller

app/code/Bluethink/CustomMenu/Controller/Adminhtml/Post/Index.php

All controllers have to contain a public execute method. It is called when accessing the controller. The storefront controllers are inherited from the \Magento\Framework\App\Action\Action class.

After create controller we will create layout file.

Step 3: Create menu_post_index.xml

app/code/Bluethink/CustomMenu/view/adminhtml/layout/menu_post_index.xml

The layout file is an XML file which will define the page structure.

In this layout file, we declare an uiComponent for the content of this page. Basically with uiComponent, Magento allows us to create nice user interface for lists, forms etc. we need to create ui_component folder inside view/adminhtml folder.

Step 4: Create quote_listing.xml

app/code/Bluethink/CustomMenu/view/adminhtml/ui_component/quote_listing.xml

In the ui_component folder, we will finally create the UI Grid and display customer data.

Step 5: Create di.xml

app/code/Bluethink/CustomMenu/etc/di.xml

Declare resource in dependency injection file. Now we will create di.xml file which will connect to the Model to get the data for our grid.

The type is used for changing arguments of class or to pass new arguments to that class. Whereas virtualType is used to create a virtual sub-class (means we don’t have to create the .php file).

Step 6: Create UpgradeSchema.php

app/code/Bluethink/CustomMenu/Setup/UpgradeSchema.php

In this blog we use magento quote table, we need to index table for perform full text search in admin grid.

Step 7: Run command

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento cache:flush

Magento 2

You can download sample module for admin menu here.

bluethinkinc_blog

bluethinkinc_blog

2022-09-01

0

Leave a Reply

Your email address will not be published. Required fields are marked *

Find More Blogs

Enhancing Productivity with Dynamics 365: The Power of Session Restore

Spread the love Enhancing Productivity with Dynamics 365:

Salesforce Admin

Spread the love In our last blog, we discussed common

Unlocking AI with Spring Boot: Real-World Use Cases and Solutions

Spread the love Artificial Intelligence (AI) has moved from

Enhancing Performance with Reactive Java: A Beginner-Friendly Guide

Spread the love In today’s fast-paced software

Integrating Azure Function with Dynamics 365

Spread the love Signup on azure portal and make sure to

How to Create a Power Apps Component Framework (PCF) with React

Spread the love If youʼve been looking to supercharge your

Customize lead qualification for a seamless experience

Spread the love When the 2024 Release Wave 2 was launched,

Create a Custom Console Command in Spryker

Spread the love In Spryker, developers can create custom

SALESFORCE

Spread the love Salesforce is a cloud-based software

CRUD Operation in Spryker Backoffice with a Custom Module

Spread the love Spryker is a highly flexible and modular

bluethinkinc Blogs