Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 118 characters in body
Source Link
7ochem
  • 7.6k
  • 14
  • 52
  • 80

I want to create a grid menu in the admin panel, I. I'm stuck inat creating layout using compnents,components. I have some records in a table. Now how can iI display it in the admin. grid?

The following is the code that i knowI now used,.

I createcreated module.xmlHiren/Employee/etc/module.xml in,

path : Hiren/Employee/etc/module.xml

I create routes.xml in,

path : created **Hiren/Employee/etc/adminhtml/routes.xml*:

I createcreated menu.xmlHiren/Employee/etc/adminhtml/menu.xml in,

path : Hiren/Employee/etc/adminhtml/menu.xml

I createcreated InstallSchema.phpHiren/Employee/Setup/InstallSchema.php in,

path : Hiren/Employee/Setup/InstallSchema.php

I createcreated Index.phpHiren/Employee/Controller/Adminhtml/view/Index.php in,

path : Hiren/Employee/Controller/Adminhtml/view/index.php

result

Thank you in advance

I want to create grid menu in admin panel, I stuck in creating layout using compnents, I have some records in table how can i display it in admin.

The following is the code that i know used,

I create module.xml in,

path : Hiren/Employee/etc/module.xml

I create routes.xml in,

path : Hiren/Employee/etc/adminhtml/routes.xml

I create menu.xml in,

path : Hiren/Employee/etc/adminhtml/menu.xml

I create InstallSchema.php in,

path : Hiren/Employee/Setup/InstallSchema.php

I create Index.php in,

path : Hiren/Employee/Controller/Adminhtml/view/index.php

result

Thank you in advance

I want to create a grid menu in the admin panel. I'm stuck at creating layout using components. I have some records in a table. Now how can I display it in the admin grid?

The following is the code that I now used.

I created Hiren/Employee/etc/module.xml:

I created **Hiren/Employee/etc/adminhtml/routes.xml*:

I created Hiren/Employee/etc/adminhtml/menu.xml:

I created Hiren/Employee/Setup/InstallSchema.php:

I created Hiren/Employee/Controller/Adminhtml/view/Index.php:

result

Magento 2 - How to create custom grid menu in admin?

iI want to create grid menu in admin panel, iI stuck in creating layout using compnents, iI have some records in table how can i display it in admin.

theThe following is the code that i know :Dused,

I create module.xml in,

path : Hiren\Employee\etcHiren/Employee/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Hiren_Employee" setup_version="0.0.1"/>
</config>

I create routes.xml in,

path : Hiren\Employee\etc\adminhtmlHiren/Employee/etc/adminhtml/routes.xml

I create menu.xml in,

path : Hiren\Employee\etc\adminhtmlHiren/Employee/etc/adminhtml/menu.xml

I create InstallSchema.php in,

path : Hiren\Employee\SetupHiren/Employee/Setup/InstallSchema.php

<?php

namespace Hiren\Employee\Setup;

class InstallSchema implements \Magento\Framework\Setup\InstallSchemaInterface
{
 
    public function install(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();
        if (!$installer->tableExists('emp_table'))
        {
            $table = $installer->getConnection()->newTable($installer->getTable('emp_table'))
                ->addColumn('no', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'no')
                ->addColumn('name', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, ['nullable => false'], 'Name')
                ->addColumn('city', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, [], 'city')
                ->setComment('Employee Table');

            $installer->getConnection()->createTable($table);
            $installer->getConnection()->addIndex($installer->getTable('emp_table'), $setup->getIdxName($installer->getTable('emp_table'), ['no', 'name', 'city'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT), ['no', 'name', 'city'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT);
        }
        $installer->endSetup();
    }
 
}

I create Index.php in,

path : Hiren\Employee\Controller\Adminhtml\viewHiren/Employee/Controller/Adminhtml/view/index.php

<?php

namespace Hiren\Employee\Controller\Adminhtml\view;

class Index extends \Magento\Backend\App\Action
{
 
    protected $resultPageFactory = false;

    public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory)
    {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->prepend((__('VIEW')));
 
        return $resultPage;
    }
}

How to create custom grid menu in admin?

i want to create grid menu in admin panel, i stuck in creating layout using compnents, i have some records in table how can i display it in admin

the following is the code that i know :D

module.xml

path : Hiren\Employee\etc

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Hiren_Employee" setup_version="0.0.1"/>
</config>

routes.xml

path : Hiren\Employee\etc\adminhtml

menu.xml

path : Hiren\Employee\etc\adminhtml

InstallSchema.php

path : Hiren\Employee\Setup

<?php

namespace Hiren\Employee\Setup;

class InstallSchema implements \Magento\Framework\Setup\InstallSchemaInterface
{
 
public function install(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context)
{
    $installer = $setup;
    $installer->startSetup();
    if (!$installer->tableExists('emp_table'))
    {
        $table = $installer->getConnection()->newTable($installer->getTable('emp_table'))
                ->addColumn('no', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'no')
                ->addColumn('name', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, ['nullable => false'], 'Name')
                ->addColumn('city', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, [], 'city')
                ->setComment('Employee Table');

        $installer->getConnection()->createTable($table);
        $installer->getConnection()->addIndex($installer->getTable('emp_table'), $setup->getIdxName($installer->getTable('emp_table'), ['no', 'name', 'city'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT), ['no', 'name', 'city'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT);
    }
    $installer->endSetup();
}
 
}

Index.php

path : Hiren\Employee\Controller\Adminhtml\view

<?php

namespace Hiren\Employee\Controller\Adminhtml\view;

class Index extends \Magento\Backend\App\Action
{
 
protected $resultPageFactory = false;

public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory)
{
    parent::__construct($context);
    $this->resultPageFactory = $resultPageFactory;
}

public function execute()
{
    $resultPage = $this->resultPageFactory->create();
    $resultPage->getConfig()->getTitle()->prepend((__('VIEW')));
 
    return $resultPage;
}
}

Magento 2 - How to create custom grid menu in admin?

I want to create grid menu in admin panel, I stuck in creating layout using compnents, I have some records in table how can i display it in admin.

The following is the code that i know used,

I create module.xml in,

path : Hiren/Employee/etc/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Hiren_Employee" setup_version="0.0.1"/>
</config>

I create routes.xml in,

path : Hiren/Employee/etc/adminhtml/routes.xml

I create menu.xml in,

path : Hiren/Employee/etc/adminhtml/menu.xml

I create InstallSchema.php in,

path : Hiren/Employee/Setup/InstallSchema.php

<?php

namespace Hiren\Employee\Setup;

class InstallSchema implements \Magento\Framework\Setup\InstallSchemaInterface
{
    public function install(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context)
    {
        $installer = $setup;
        $installer->startSetup();
        if (!$installer->tableExists('emp_table'))
        {
            $table = $installer->getConnection()->newTable($installer->getTable('emp_table'))
            ->addColumn('no', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'no')
            ->addColumn('name', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, ['nullable => false'], 'Name')
            ->addColumn('city', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, [], 'city')->setComment('Employee Table');

            $installer->getConnection()->createTable($table);
            $installer->getConnection()->addIndex($installer->getTable('emp_table'), $setup->getIdxName($installer->getTable('emp_table'), ['no', 'name', 'city'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT), ['no', 'name', 'city'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT);
        }
        $installer->endSetup();
    }
}

I create Index.php in,

path : Hiren/Employee/Controller/Adminhtml/view/index.php

<?php

namespace Hiren\Employee\Controller\Adminhtml\view;

class Index extends \Magento\Backend\App\Action
{
    protected $resultPageFactory = false;

    public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory)
    {
        parent::__construct($context);
        $this->resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->prepend((__('VIEW')));
        return $resultPage;
    }
}
Source Link
Hiren
  • 1.1k
  • 8
  • 29

How to create custom grid menu in admin?

i want to create grid menu in admin panel, i stuck in creating layout using compnents, i have some records in table how can i display it in admin

the following is the code that i know :D

module.xml

path : Hiren\Employee\etc

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Hiren_Employee" setup_version="0.0.1"/>
</config>

routes.xml

path : Hiren\Employee\etc\adminhtml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
    <route id="employee" frontName="employee">
        <module name="Hiren_Employee"/>
    </route>
</router>
</config>

menu.xml

path : Hiren\Employee\etc\adminhtml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
    <add id="Hiren_Employee::EmpManage" title="Manage Employee" module="Hiren_Employee" sortOrder="51" resource="Hiren_Employee::EmpManage"/>
    <add id="Hiren_Employee::viewData" title="View" module="Hiren_GridMenu" sortOrder="10" action="employee/view" resource="Hiren_Employee::viewData" parent="Hiren_Employee::EmpManage"/>       
</menu>
</config>

InstallSchema.php

path : Hiren\Employee\Setup

<?php

namespace Hiren\Employee\Setup;

class InstallSchema implements \Magento\Framework\Setup\InstallSchemaInterface
{

public function install(\Magento\Framework\Setup\SchemaSetupInterface $setup, \Magento\Framework\Setup\ModuleContextInterface $context)
{
    $installer = $setup;
    $installer->startSetup();
    if (!$installer->tableExists('emp_table'))
    {
        $table = $installer->getConnection()->newTable($installer->getTable('emp_table'))
                ->addColumn('no', \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'no')
                ->addColumn('name', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, ['nullable => false'], 'Name')
                ->addColumn('city', \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 255, [], 'city')
                ->setComment('Employee Table');

        $installer->getConnection()->createTable($table);
        $installer->getConnection()->addIndex($installer->getTable('emp_table'), $setup->getIdxName($installer->getTable('emp_table'), ['no', 'name', 'city'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT), ['no', 'name', 'city'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT);
    }
    $installer->endSetup();
}

}

Index.php

path : Hiren\Employee\Controller\Adminhtml\view

<?php

namespace Hiren\Employee\Controller\Adminhtml\view;

class Index extends \Magento\Backend\App\Action
{

protected $resultPageFactory = false;

public function __construct(\Magento\Backend\App\Action\Context $context, \Magento\Framework\View\Result\PageFactory $resultPageFactory)
{
    parent::__construct($context);
    $this->resultPageFactory = $resultPageFactory;
}

public function execute()
{
    $resultPage = $this->resultPageFactory->create();
    $resultPage->getConfig()->getTitle()->prepend((__('VIEW')));

    return $resultPage;
}
}

result

Thank you in advance