Skip to main content

Magento 2 custom module grid not showing

 Magento 2 is an eCommerce framework. Magento 2 divided into two editions community edition and enterprise edition. Sometimes, developer-facing issues on backend Magento provides many featured for Magento developers. Like Theme integration, Extension development, Data Migration, product import-export.

In this blog, We will discuss on how to create custom grid on admin panel. Before we start, First we need to create a custom extension. also, Need to define a custom table. 

Let's Start!!!

Module Name: StudentManagement

Company Name: TryCoder

Database TableName: studentinfo

Database Table FieldName: 

  1. id
  2. student_name
  3. student_class
  4. mobile_no
  5. student_info
Module Path:  app/code/TryCoder/StudentManagement

Create "etc" folder inside the module and add below files:

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">

</config>

module.xml

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">

    <module name="TryCoder_StudentManagement" setup_version="1.0.0">

        <sequence>

            <module name="Magento_Backend"/>

             <module name="Magento_Sales"/>

            <module name="Magento_Quote"/>

            <module name="Magento_Checkout"/>

            <module name="Magento_Cms"/>

        </sequence>

</module>

</config>

  Create "Setup" folder inside the module and add below file:

InstallSchema.php

<?php

namespace TryCoder\StudentManagement\Setup;

use Magento\Framework\Setup\InstallSchemaInterface;

use Magento\Framework\Setup\ModuleContextInterface;

use Magento\Framework\Setup\SchemaSetupInterface;

use Magento\Framework\DB\Ddl\Table;

use Magento\Framework\DB\Adapter\AdapterInterface;

class InstallSchema implements InstallSchemaInterface

{

    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)

    {

        $installer = $setup;

        $installer->startSetup();

        if (version_compare($context->getVersion(), '1.0.0') < 0){

$installer->run('create table studentinfo(id int not null auto_increment, student_name varchar(100),  student_class varchar(100),  mobile_no varchar(100), student_info text(100), primary key(id))');

}

        $installer->endSetup();

    }

}

Under Module Root Dir add below two file:

composer.json:

{

    "name": "trycoder/studentmanagement",

    "description": "TryCoder StudentManagement",

    "require": {

      "php": "~5.6.0|7.0.2|~7.0.6",

      "magento/module-store": "0.74.0-beta4",

      "magento/module-theme": "0.74.0-beta4",

      "magento/module-widget": "0.74.0-beta4",

      "magento/module-backend": "0.74.0-beta4",

      "magento/module-catalog": "0.74.0-beta4",

      "magento/module-email": "0.74.0-beta4",

      "magento/module-ui": "0.74.0-beta4",

      "magento/module-variable": "0.74.0-beta4",

      "magento/module-media-storage": "0.74.0-beta4",

      "magento/framework": "0.74.0-beta4",

      "magento/magento-composer-installer": "*"

    },

    "type": "magento2-module",

    "version": "0.74.0-beta4",

    "license": [

        "OSL-3.0",

        "AFL-3.0"

    ],

    "extra": {

        "map": [

            [

                "*",

                "TryCoder/StudentManagement"

            ]

        ]

    }

}

registration.php

<?php

\Magento\Framework\Component\ComponentRegistrar::register(

    \Magento\Framework\Component\ComponentRegistrar::MODULE,

    'TryCoder_StudentManagement',

    __DIR__

); 

After added above all files, We need to run below command and enable module in our projects.

  1. php bin/magento c:c
  2. php bin/magento deploy:mode:set development
  3. php bin/magento s:up
  4. php bin/magento s:d:c
  5. php bin/magento s:s:d -f
  6. php bin/magento c:c

Then, Give folder permission if required and check module on app/etc/config.php

Now, I am writing coding related module grid creating. We can create adminpanel grid below using two ways.

  1. Create grid using UI components
  2. Create grid using Block Class
Before we start discussion let me add dummy data on "studentinfo" table using phpmyadmin.
Let's discuss on step by step

1. Create Grid By UI components



Comments

Popular posts from this blog

Introduction to flask

Hello. Welcome to another session on this platform. If you are new here, please do checkout our previous articles on python programming language and stay excited on this session because we are entering into one of python’s web-based application called flask. In this article, we are going to see the following What is flask Prequistes Installation of flask in python Some of flask template engine. What is flask? Flask is one of python-based framework which is used to create web applications. Flight is a very light web framework. During installation, flask comes with pre-installed modules and functions which are used to backup your own web applications. Flask is very easy to understand and perfect go-to for beginners and with flask, a web server can run in less than 3 lines of code. Prequistes Before learning flask, we recommend the reader to have a basic mastery of python concepts. Installation of flask  Before installing flask, we have to checked if python has been installed or. If n...

How to generate random numbers using NumP1

Hello. Welcome to another edition on this platform. For more better understanding, do checkout our YouTube channel to get the video tutorial. In this article of today, we are going to see how to generate random numbers using any of the following methods: Generating a random number Generating a random float and integer Generating random number arrays Generating random number from an array What is a random number? This is a number which cannot be predicted before its occurrence. This number might not different every time. Programmatically, they are two categories of random numbers:     Pseudo-Random numbers       True Random numbers. Just as programs which are written by programmers are a set of instructions, we must follow an algorithm to generate random numbers. Random numbers which are generated using an algorithm are called Pseudo-Random numbers. To generate a true random number, it is important to get the data from sources such as the keyboards, mou...

Introduction to Django

Hello. Welcome to another session on this platform. If you are new here, please do checkout our previous articles on python programming language and stay excited on this session. we are entering into one of python’s application called Django. In this article, we are going to discuss the following: What is Django Why must we use Django  A brief history of Django Installation of Django Popularity of Django What is Django? Python has so many framework application and Django happen to be one of them. Being a python-based-framework, it is used to quickly create web applications.  When building websites, django provides similar ready-made components to handle user authentication, forms, a way to upload components. Why use django? Django is very fast. It takes applications from concept to applications very quickly Django has thousand available packages in it when it is installed. With django, we can launch web applications is a matter of hours. Django is a highly is secured and helps...