Magento 2 - How to create custom grid menu in admin?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?I have created an extension to show Customer Company Name in Order grid. But when creating new order, order is not showing in order gridHow to create a admin report grid?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2 admin menu extensionSupport Multiselect Attribute in Admin Grid Column without UIMagento 2.2.5: Add, Update and Delete existing products Custom Options
Why was Germany not as successful as other Europeans in establishing overseas colonies?
What does YCWCYODFTRFDTY mean?
Multiple options for Pseudonyms
gnu parallel how to use with ffmpeg
Are Boeing 737-800’s grounded?
How to determine the actual or "true" resolution of a digital photograph?
What is a Recurrent Neural Network?
When and why did journal article titles become descriptive, rather than creatively allusive?
Is thermodynamics only applicable to systems in equilibrium?
Subtleties of choosing the sequence of tenses in Russian
A non-technological, repeating, visible object in the sky, holding its position in the sky for hours
How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?
In gnome-terminal only 2 out of 3 zoom keys work
Pressure to defend the relevance of one's area of mathematics
How to back up a running remote server?
Toggle Overlays shortcut?
Is it possible to Ready a spell to be cast just before the start of your next turn by having the trigger be an ally's attack?
Pulling the rope with one hand is as heavy as with two hands?
Reverse the word in a string with the same order in javascript
Does a creature that is immune to a condition still make a saving throw?
How to creep the reader out with what seems like a normal person?
Examples of non trivial equivalence relations , I mean equivalence relations without the expression " same ... as" in their definition?
How does a Swashbuckler rogue "fight with two weapons while safely darting away"?
Will tsunami waves travel forever if there was no land?
Magento 2 - How to create custom grid menu in admin?
How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?I have created an extension to show Customer Company Name in Order grid. But when creating new order, order is not showing in order gridHow to create a admin report grid?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2 admin menu extensionSupport Multiselect Attribute in Admin Grid Column without UIMagento 2.2.5: Add, Update and Delete existing products Custom Options
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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:
<?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 created **Hiren/Employee/etc/adminhtml/routes.xml*:
<?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>
I created Hiren/Employee/etc/adminhtml/menu.xml:
<?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>
I created Hiren/Employee/Setup/InstallSchema.php:
<?php
namespace HirenEmployeeSetup;
class InstallSchema implements MagentoFrameworkSetupInstallSchemaInterface
public function install(MagentoFrameworkSetupSchemaSetupInterface $setup, MagentoFrameworkSetupModuleContextInterface $context)
$installer = $setup;
$installer->startSetup();
if (!$installer->tableExists('emp_table'))
$table = $installer->getConnection()->newTable($installer->getTable('emp_table'))
->addColumn('no', MagentoFrameworkDBDdlTable::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'no')
->addColumn('name', MagentoFrameworkDBDdlTable::TYPE_TEXT, 255, ['nullable => false'], 'Name')
->addColumn('city', MagentoFrameworkDBDdlTable::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'], MagentoFrameworkDBAdapterAdapterInterface::INDEX_TYPE_FULLTEXT), ['no', 'name', 'city'], MagentoFrameworkDBAdapterAdapterInterface::INDEX_TYPE_FULLTEXT);
$installer->endSetup();
I created Hiren/Employee/Controller/Adminhtml/view/Index.php:
<?php
namespace HirenEmployeeControllerAdminhtmlview;
class Index extends MagentoBackendAppAction
protected $resultPageFactory = false;
public function __construct(MagentoBackendAppActionContext $context, MagentoFrameworkViewResultPageFactory $resultPageFactory)
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
public function execute()
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend((__('VIEW')));
return $resultPage;

magento2 adminhtml magento2.2 grid grid-layout
add a comment |
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:
<?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 created **Hiren/Employee/etc/adminhtml/routes.xml*:
<?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>
I created Hiren/Employee/etc/adminhtml/menu.xml:
<?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>
I created Hiren/Employee/Setup/InstallSchema.php:
<?php
namespace HirenEmployeeSetup;
class InstallSchema implements MagentoFrameworkSetupInstallSchemaInterface
public function install(MagentoFrameworkSetupSchemaSetupInterface $setup, MagentoFrameworkSetupModuleContextInterface $context)
$installer = $setup;
$installer->startSetup();
if (!$installer->tableExists('emp_table'))
$table = $installer->getConnection()->newTable($installer->getTable('emp_table'))
->addColumn('no', MagentoFrameworkDBDdlTable::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'no')
->addColumn('name', MagentoFrameworkDBDdlTable::TYPE_TEXT, 255, ['nullable => false'], 'Name')
->addColumn('city', MagentoFrameworkDBDdlTable::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'], MagentoFrameworkDBAdapterAdapterInterface::INDEX_TYPE_FULLTEXT), ['no', 'name', 'city'], MagentoFrameworkDBAdapterAdapterInterface::INDEX_TYPE_FULLTEXT);
$installer->endSetup();
I created Hiren/Employee/Controller/Adminhtml/view/Index.php:
<?php
namespace HirenEmployeeControllerAdminhtmlview;
class Index extends MagentoBackendAppAction
protected $resultPageFactory = false;
public function __construct(MagentoBackendAppActionContext $context, MagentoFrameworkViewResultPageFactory $resultPageFactory)
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
public function execute()
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend((__('VIEW')));
return $resultPage;

magento2 adminhtml magento2.2 grid grid-layout
have you created admin routes in etcadminhtmlroutes.xml?
– Abdul
Mar 29 '18 at 12:58
yes i created admin routes @Abdul
– user4536
Mar 30 '18 at 3:32
add a comment |
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:
<?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 created **Hiren/Employee/etc/adminhtml/routes.xml*:
<?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>
I created Hiren/Employee/etc/adminhtml/menu.xml:
<?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>
I created Hiren/Employee/Setup/InstallSchema.php:
<?php
namespace HirenEmployeeSetup;
class InstallSchema implements MagentoFrameworkSetupInstallSchemaInterface
public function install(MagentoFrameworkSetupSchemaSetupInterface $setup, MagentoFrameworkSetupModuleContextInterface $context)
$installer = $setup;
$installer->startSetup();
if (!$installer->tableExists('emp_table'))
$table = $installer->getConnection()->newTable($installer->getTable('emp_table'))
->addColumn('no', MagentoFrameworkDBDdlTable::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'no')
->addColumn('name', MagentoFrameworkDBDdlTable::TYPE_TEXT, 255, ['nullable => false'], 'Name')
->addColumn('city', MagentoFrameworkDBDdlTable::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'], MagentoFrameworkDBAdapterAdapterInterface::INDEX_TYPE_FULLTEXT), ['no', 'name', 'city'], MagentoFrameworkDBAdapterAdapterInterface::INDEX_TYPE_FULLTEXT);
$installer->endSetup();
I created Hiren/Employee/Controller/Adminhtml/view/Index.php:
<?php
namespace HirenEmployeeControllerAdminhtmlview;
class Index extends MagentoBackendAppAction
protected $resultPageFactory = false;
public function __construct(MagentoBackendAppActionContext $context, MagentoFrameworkViewResultPageFactory $resultPageFactory)
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
public function execute()
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend((__('VIEW')));
return $resultPage;

magento2 adminhtml magento2.2 grid grid-layout
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:
<?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 created **Hiren/Employee/etc/adminhtml/routes.xml*:
<?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>
I created Hiren/Employee/etc/adminhtml/menu.xml:
<?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>
I created Hiren/Employee/Setup/InstallSchema.php:
<?php
namespace HirenEmployeeSetup;
class InstallSchema implements MagentoFrameworkSetupInstallSchemaInterface
public function install(MagentoFrameworkSetupSchemaSetupInterface $setup, MagentoFrameworkSetupModuleContextInterface $context)
$installer = $setup;
$installer->startSetup();
if (!$installer->tableExists('emp_table'))
$table = $installer->getConnection()->newTable($installer->getTable('emp_table'))
->addColumn('no', MagentoFrameworkDBDdlTable::TYPE_INTEGER, null, ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 'no')
->addColumn('name', MagentoFrameworkDBDdlTable::TYPE_TEXT, 255, ['nullable => false'], 'Name')
->addColumn('city', MagentoFrameworkDBDdlTable::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'], MagentoFrameworkDBAdapterAdapterInterface::INDEX_TYPE_FULLTEXT), ['no', 'name', 'city'], MagentoFrameworkDBAdapterAdapterInterface::INDEX_TYPE_FULLTEXT);
$installer->endSetup();
I created Hiren/Employee/Controller/Adminhtml/view/Index.php:
<?php
namespace HirenEmployeeControllerAdminhtmlview;
class Index extends MagentoBackendAppAction
protected $resultPageFactory = false;
public function __construct(MagentoBackendAppActionContext $context, MagentoFrameworkViewResultPageFactory $resultPageFactory)
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
public function execute()
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->prepend((__('VIEW')));
return $resultPage;

magento2 adminhtml magento2.2 grid grid-layout
magento2 adminhtml magento2.2 grid grid-layout
edited Apr 5 '18 at 8:00
7ochem
5,88493770
5,88493770
asked Mar 29 '18 at 12:03
user4536user4536
6812
6812
have you created admin routes in etcadminhtmlroutes.xml?
– Abdul
Mar 29 '18 at 12:58
yes i created admin routes @Abdul
– user4536
Mar 30 '18 at 3:32
add a comment |
have you created admin routes in etcadminhtmlroutes.xml?
– Abdul
Mar 29 '18 at 12:58
yes i created admin routes @Abdul
– user4536
Mar 30 '18 at 3:32
have you created admin routes in etcadminhtmlroutes.xml?
– Abdul
Mar 29 '18 at 12:58
have you created admin routes in etcadminhtmlroutes.xml?
– Abdul
Mar 29 '18 at 12:58
yes i created admin routes @Abdul
– user4536
Mar 30 '18 at 3:32
yes i created admin routes @Abdul
– user4536
Mar 30 '18 at 3:32
add a comment |
3 Answers
3
active
oldest
votes
You will need to create mass action and grid directory to show data from the database in the grid.
appcodeHirenEmployeeviewadminhtmltemplatesemployeegrid
massaction_extended.phtml
and
appcodeHirenEmployeeviewadminhtmltemplatesemployee
employee.phtml
You can create the complete module from module creator
http://www.silksoftware.com/magento-module-creator/magento2x.php
Hope this will help you.
add a comment |
Use https://mage2gen.com/ to generate whole module - the only thing you probably will need is to configure grid columns and form fields.
add a comment |
Create view/adminhtml/layout/employee_view_index.xml file,
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="HirenEmployeeBlockAdminhtmlGrid" name="grid_grid_listing"/>
</referenceContainer>
</body>
</page>
Create Hiren/Employee/Block/Adminhtml/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtml;
class Grid extends MagentoBackendBlockWidgetContainer
protected $_template = 'grid/view.phtml';
public function __construct(
MagentoBackendBlockWidgetContext $context,
array $data = []
)
parent::__construct($context, $data);
protected function _prepareLayout()
$addButtonProps = [
'id' => 'add_new_grid',
'label' => __('Add New'),
'class' => 'add',
'button_class' => '',
'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
'options' => $this->_getAddButtonOptions(),
];
$this->buttonList->add('add_new', $addButtonProps);
$this->setChild(
'grid',
$this->getLayout()->createBlock('HirenEmployeeBlockAdminhtmlGridGrid',
'grid.view.grid'));
return parent::_prepareLayout();
protected function _getAddButtonOptions()
$splitButtonOptions[] = [
'label' => __('Add New'),
'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
];
return $splitButtonOptions;
protected function _getCreateUrl()
return $this->getUrl(
'employee/*/new'
);
public function getGridHtml()
return $this->getChildHtml('grid');
Create Hiren/Employee/Block/Adminhtml/Grid/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtmlGrid;
class Grid extends MagentoBackendBlockWidgetGridExtended
protected $moduleManager;
protected $_gridFactory;
protected $_status;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoBackendHelperData $backendHelper,
HirenEmployeeModelGridFactory $gridFactory,
HirenEmployeeModelStatus $status,
MagentoFrameworkModuleManager $moduleManager,
array $data = []
)
$this->_gridFactory = $gridFactory;
$this->_status = $status;
$this->moduleManager = $moduleManager;
parent::__construct($context, $backendHelper, $data);
protected function _construct()
parent::_construct();
$this->setId('gridGrid');
$this->setDefaultSort('id');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
$this->setVarNameFilter('grid_record');
protected function _prepareCollection()
$collection = $this->_gridFactory->create()->getCollection();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
protected function _prepareColumns()
$this->addColumn(
'no',
[
'header' => __('No'),
'type' => 'number',
'index' => 'id',
'header_css_class' => 'col-id',
'column_css_class' => 'col-id'
]
);
$this->addColumn(
'name',
[
'header' => __('Name'),
'index' => 'name',
'class' => 'xxx'
]
);
$this->addColumn(
'city',
[
'header' => __('City'),
'index' => 'city',
'class' => 'xxx'
]
);
$block = $this->getLayout()->getBlock('grid.bottom.links');
if ($block)
$this->setChild('grid.bottom.links', $block);
return parent::_prepareColumns();
public function getGridUrl()
return $this->getUrl('employee/*/grid', ['_current' => true]);
public function getRowUrl($row)
return $this->getUrl(
'employee/*/edit',
['id' => $row->getId()]
);
Please try this.
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f220366%2fmagento-2-how-to-create-custom-grid-menu-in-admin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
You will need to create mass action and grid directory to show data from the database in the grid.
appcodeHirenEmployeeviewadminhtmltemplatesemployeegrid
massaction_extended.phtml
and
appcodeHirenEmployeeviewadminhtmltemplatesemployee
employee.phtml
You can create the complete module from module creator
http://www.silksoftware.com/magento-module-creator/magento2x.php
Hope this will help you.
add a comment |
You will need to create mass action and grid directory to show data from the database in the grid.
appcodeHirenEmployeeviewadminhtmltemplatesemployeegrid
massaction_extended.phtml
and
appcodeHirenEmployeeviewadminhtmltemplatesemployee
employee.phtml
You can create the complete module from module creator
http://www.silksoftware.com/magento-module-creator/magento2x.php
Hope this will help you.
add a comment |
You will need to create mass action and grid directory to show data from the database in the grid.
appcodeHirenEmployeeviewadminhtmltemplatesemployeegrid
massaction_extended.phtml
and
appcodeHirenEmployeeviewadminhtmltemplatesemployee
employee.phtml
You can create the complete module from module creator
http://www.silksoftware.com/magento-module-creator/magento2x.php
Hope this will help you.
You will need to create mass action and grid directory to show data from the database in the grid.
appcodeHirenEmployeeviewadminhtmltemplatesemployeegrid
massaction_extended.phtml
and
appcodeHirenEmployeeviewadminhtmltemplatesemployee
employee.phtml
You can create the complete module from module creator
http://www.silksoftware.com/magento-module-creator/magento2x.php
Hope this will help you.
edited Mar 29 '18 at 13:18
Rama Chandran M
2,74181530
2,74181530
answered Mar 29 '18 at 13:14
Arvind TiwariArvind Tiwari
11
11
add a comment |
add a comment |
Use https://mage2gen.com/ to generate whole module - the only thing you probably will need is to configure grid columns and form fields.
add a comment |
Use https://mage2gen.com/ to generate whole module - the only thing you probably will need is to configure grid columns and form fields.
add a comment |
Use https://mage2gen.com/ to generate whole module - the only thing you probably will need is to configure grid columns and form fields.
Use https://mage2gen.com/ to generate whole module - the only thing you probably will need is to configure grid columns and form fields.
answered Mar 29 '18 at 14:22
dudziodudzio
1138
1138
add a comment |
add a comment |
Create view/adminhtml/layout/employee_view_index.xml file,
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="HirenEmployeeBlockAdminhtmlGrid" name="grid_grid_listing"/>
</referenceContainer>
</body>
</page>
Create Hiren/Employee/Block/Adminhtml/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtml;
class Grid extends MagentoBackendBlockWidgetContainer
protected $_template = 'grid/view.phtml';
public function __construct(
MagentoBackendBlockWidgetContext $context,
array $data = []
)
parent::__construct($context, $data);
protected function _prepareLayout()
$addButtonProps = [
'id' => 'add_new_grid',
'label' => __('Add New'),
'class' => 'add',
'button_class' => '',
'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
'options' => $this->_getAddButtonOptions(),
];
$this->buttonList->add('add_new', $addButtonProps);
$this->setChild(
'grid',
$this->getLayout()->createBlock('HirenEmployeeBlockAdminhtmlGridGrid',
'grid.view.grid'));
return parent::_prepareLayout();
protected function _getAddButtonOptions()
$splitButtonOptions[] = [
'label' => __('Add New'),
'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
];
return $splitButtonOptions;
protected function _getCreateUrl()
return $this->getUrl(
'employee/*/new'
);
public function getGridHtml()
return $this->getChildHtml('grid');
Create Hiren/Employee/Block/Adminhtml/Grid/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtmlGrid;
class Grid extends MagentoBackendBlockWidgetGridExtended
protected $moduleManager;
protected $_gridFactory;
protected $_status;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoBackendHelperData $backendHelper,
HirenEmployeeModelGridFactory $gridFactory,
HirenEmployeeModelStatus $status,
MagentoFrameworkModuleManager $moduleManager,
array $data = []
)
$this->_gridFactory = $gridFactory;
$this->_status = $status;
$this->moduleManager = $moduleManager;
parent::__construct($context, $backendHelper, $data);
protected function _construct()
parent::_construct();
$this->setId('gridGrid');
$this->setDefaultSort('id');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
$this->setVarNameFilter('grid_record');
protected function _prepareCollection()
$collection = $this->_gridFactory->create()->getCollection();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
protected function _prepareColumns()
$this->addColumn(
'no',
[
'header' => __('No'),
'type' => 'number',
'index' => 'id',
'header_css_class' => 'col-id',
'column_css_class' => 'col-id'
]
);
$this->addColumn(
'name',
[
'header' => __('Name'),
'index' => 'name',
'class' => 'xxx'
]
);
$this->addColumn(
'city',
[
'header' => __('City'),
'index' => 'city',
'class' => 'xxx'
]
);
$block = $this->getLayout()->getBlock('grid.bottom.links');
if ($block)
$this->setChild('grid.bottom.links', $block);
return parent::_prepareColumns();
public function getGridUrl()
return $this->getUrl('employee/*/grid', ['_current' => true]);
public function getRowUrl($row)
return $this->getUrl(
'employee/*/edit',
['id' => $row->getId()]
);
Please try this.
add a comment |
Create view/adminhtml/layout/employee_view_index.xml file,
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="HirenEmployeeBlockAdminhtmlGrid" name="grid_grid_listing"/>
</referenceContainer>
</body>
</page>
Create Hiren/Employee/Block/Adminhtml/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtml;
class Grid extends MagentoBackendBlockWidgetContainer
protected $_template = 'grid/view.phtml';
public function __construct(
MagentoBackendBlockWidgetContext $context,
array $data = []
)
parent::__construct($context, $data);
protected function _prepareLayout()
$addButtonProps = [
'id' => 'add_new_grid',
'label' => __('Add New'),
'class' => 'add',
'button_class' => '',
'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
'options' => $this->_getAddButtonOptions(),
];
$this->buttonList->add('add_new', $addButtonProps);
$this->setChild(
'grid',
$this->getLayout()->createBlock('HirenEmployeeBlockAdminhtmlGridGrid',
'grid.view.grid'));
return parent::_prepareLayout();
protected function _getAddButtonOptions()
$splitButtonOptions[] = [
'label' => __('Add New'),
'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
];
return $splitButtonOptions;
protected function _getCreateUrl()
return $this->getUrl(
'employee/*/new'
);
public function getGridHtml()
return $this->getChildHtml('grid');
Create Hiren/Employee/Block/Adminhtml/Grid/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtmlGrid;
class Grid extends MagentoBackendBlockWidgetGridExtended
protected $moduleManager;
protected $_gridFactory;
protected $_status;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoBackendHelperData $backendHelper,
HirenEmployeeModelGridFactory $gridFactory,
HirenEmployeeModelStatus $status,
MagentoFrameworkModuleManager $moduleManager,
array $data = []
)
$this->_gridFactory = $gridFactory;
$this->_status = $status;
$this->moduleManager = $moduleManager;
parent::__construct($context, $backendHelper, $data);
protected function _construct()
parent::_construct();
$this->setId('gridGrid');
$this->setDefaultSort('id');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
$this->setVarNameFilter('grid_record');
protected function _prepareCollection()
$collection = $this->_gridFactory->create()->getCollection();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
protected function _prepareColumns()
$this->addColumn(
'no',
[
'header' => __('No'),
'type' => 'number',
'index' => 'id',
'header_css_class' => 'col-id',
'column_css_class' => 'col-id'
]
);
$this->addColumn(
'name',
[
'header' => __('Name'),
'index' => 'name',
'class' => 'xxx'
]
);
$this->addColumn(
'city',
[
'header' => __('City'),
'index' => 'city',
'class' => 'xxx'
]
);
$block = $this->getLayout()->getBlock('grid.bottom.links');
if ($block)
$this->setChild('grid.bottom.links', $block);
return parent::_prepareColumns();
public function getGridUrl()
return $this->getUrl('employee/*/grid', ['_current' => true]);
public function getRowUrl($row)
return $this->getUrl(
'employee/*/edit',
['id' => $row->getId()]
);
Please try this.
add a comment |
Create view/adminhtml/layout/employee_view_index.xml file,
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="HirenEmployeeBlockAdminhtmlGrid" name="grid_grid_listing"/>
</referenceContainer>
</body>
</page>
Create Hiren/Employee/Block/Adminhtml/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtml;
class Grid extends MagentoBackendBlockWidgetContainer
protected $_template = 'grid/view.phtml';
public function __construct(
MagentoBackendBlockWidgetContext $context,
array $data = []
)
parent::__construct($context, $data);
protected function _prepareLayout()
$addButtonProps = [
'id' => 'add_new_grid',
'label' => __('Add New'),
'class' => 'add',
'button_class' => '',
'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
'options' => $this->_getAddButtonOptions(),
];
$this->buttonList->add('add_new', $addButtonProps);
$this->setChild(
'grid',
$this->getLayout()->createBlock('HirenEmployeeBlockAdminhtmlGridGrid',
'grid.view.grid'));
return parent::_prepareLayout();
protected function _getAddButtonOptions()
$splitButtonOptions[] = [
'label' => __('Add New'),
'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
];
return $splitButtonOptions;
protected function _getCreateUrl()
return $this->getUrl(
'employee/*/new'
);
public function getGridHtml()
return $this->getChildHtml('grid');
Create Hiren/Employee/Block/Adminhtml/Grid/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtmlGrid;
class Grid extends MagentoBackendBlockWidgetGridExtended
protected $moduleManager;
protected $_gridFactory;
protected $_status;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoBackendHelperData $backendHelper,
HirenEmployeeModelGridFactory $gridFactory,
HirenEmployeeModelStatus $status,
MagentoFrameworkModuleManager $moduleManager,
array $data = []
)
$this->_gridFactory = $gridFactory;
$this->_status = $status;
$this->moduleManager = $moduleManager;
parent::__construct($context, $backendHelper, $data);
protected function _construct()
parent::_construct();
$this->setId('gridGrid');
$this->setDefaultSort('id');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
$this->setVarNameFilter('grid_record');
protected function _prepareCollection()
$collection = $this->_gridFactory->create()->getCollection();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
protected function _prepareColumns()
$this->addColumn(
'no',
[
'header' => __('No'),
'type' => 'number',
'index' => 'id',
'header_css_class' => 'col-id',
'column_css_class' => 'col-id'
]
);
$this->addColumn(
'name',
[
'header' => __('Name'),
'index' => 'name',
'class' => 'xxx'
]
);
$this->addColumn(
'city',
[
'header' => __('City'),
'index' => 'city',
'class' => 'xxx'
]
);
$block = $this->getLayout()->getBlock('grid.bottom.links');
if ($block)
$this->setChild('grid.bottom.links', $block);
return parent::_prepareColumns();
public function getGridUrl()
return $this->getUrl('employee/*/grid', ['_current' => true]);
public function getRowUrl($row)
return $this->getUrl(
'employee/*/edit',
['id' => $row->getId()]
);
Please try this.
Create view/adminhtml/layout/employee_view_index.xml file,
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="HirenEmployeeBlockAdminhtmlGrid" name="grid_grid_listing"/>
</referenceContainer>
</body>
</page>
Create Hiren/Employee/Block/Adminhtml/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtml;
class Grid extends MagentoBackendBlockWidgetContainer
protected $_template = 'grid/view.phtml';
public function __construct(
MagentoBackendBlockWidgetContext $context,
array $data = []
)
parent::__construct($context, $data);
protected function _prepareLayout()
$addButtonProps = [
'id' => 'add_new_grid',
'label' => __('Add New'),
'class' => 'add',
'button_class' => '',
'class_name' => 'MagentoBackendBlockWidgetButtonSplitButton',
'options' => $this->_getAddButtonOptions(),
];
$this->buttonList->add('add_new', $addButtonProps);
$this->setChild(
'grid',
$this->getLayout()->createBlock('HirenEmployeeBlockAdminhtmlGridGrid',
'grid.view.grid'));
return parent::_prepareLayout();
protected function _getAddButtonOptions()
$splitButtonOptions[] = [
'label' => __('Add New'),
'onclick' => "setLocation('" . $this->_getCreateUrl() . "')"
];
return $splitButtonOptions;
protected function _getCreateUrl()
return $this->getUrl(
'employee/*/new'
);
public function getGridHtml()
return $this->getChildHtml('grid');
Create Hiren/Employee/Block/Adminhtml/Grid/Grid.php
<?php
namespace HirenEmployeeBlockAdminhtmlGrid;
class Grid extends MagentoBackendBlockWidgetGridExtended
protected $moduleManager;
protected $_gridFactory;
protected $_status;
public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoBackendHelperData $backendHelper,
HirenEmployeeModelGridFactory $gridFactory,
HirenEmployeeModelStatus $status,
MagentoFrameworkModuleManager $moduleManager,
array $data = []
)
$this->_gridFactory = $gridFactory;
$this->_status = $status;
$this->moduleManager = $moduleManager;
parent::__construct($context, $backendHelper, $data);
protected function _construct()
parent::_construct();
$this->setId('gridGrid');
$this->setDefaultSort('id');
$this->setDefaultDir('DESC');
$this->setSaveParametersInSession(true);
$this->setUseAjax(true);
$this->setVarNameFilter('grid_record');
protected function _prepareCollection()
$collection = $this->_gridFactory->create()->getCollection();
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
protected function _prepareColumns()
$this->addColumn(
'no',
[
'header' => __('No'),
'type' => 'number',
'index' => 'id',
'header_css_class' => 'col-id',
'column_css_class' => 'col-id'
]
);
$this->addColumn(
'name',
[
'header' => __('Name'),
'index' => 'name',
'class' => 'xxx'
]
);
$this->addColumn(
'city',
[
'header' => __('City'),
'index' => 'city',
'class' => 'xxx'
]
);
$block = $this->getLayout()->getBlock('grid.bottom.links');
if ($block)
$this->setChild('grid.bottom.links', $block);
return parent::_prepareColumns();
public function getGridUrl()
return $this->getUrl('employee/*/grid', ['_current' => true]);
public function getRowUrl($row)
return $this->getUrl(
'employee/*/edit',
['id' => $row->getId()]
);
Please try this.
answered Apr 5 '18 at 9:53
Emipro Technologies Pvt. Ltd.Emipro Technologies Pvt. Ltd.
2,6581925
2,6581925
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f220366%2fmagento-2-how-to-create-custom-grid-menu-in-admin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
have you created admin routes in etcadminhtmlroutes.xml?
– Abdul
Mar 29 '18 at 12:58
yes i created admin routes @Abdul
– user4536
Mar 30 '18 at 3:32