{"id":48474,"date":"2016-05-09T09:39:01","date_gmt":"2016-05-09T09:39:01","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=48474"},"modified":"2024-02-21T06:41:26","modified_gmt":"2024-02-21T06:41:26","slug":"create-collection-grid-editadd-grid-row-installer-magento2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/","title":{"rendered":"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">Here we create Collection Grid , edit\/add grid row and installer in Magento2<\/h3>\n\n\n\n<p>Before starting the code section, let us create the directory structure that we will need for create admin grid edit\/add grid row and installer.<\/p>\n\n\n\n<p>app\/code\/Webkul\/Grid<br>app\/code\/Webkul\/Grid\/etc<br>app\/code\/Webkul\/Grid\/etc\/Adminhtml<br>app\/code\/Webkul\/Grid\/Block\/Adminhtml<br>app\/code\/Webkul\/Grid\/Block\/Adminhtml\/Grid<br>app\/code\/Webkul\/Grid\/Block\/Adminhtml\/Grid\/Edit<br>app\/code\/Webkul\/Grid\/Model<br>app\/code\/Webkul\/Grid\/Model\/ResourceModel<br>app\/code\/Webkul\/Grid\/Model\/ResourceModel\/Grid<br>app\/code\/Webkul\/Grid\/Setup<br>app\/code\/Webkul\/Grid\/Controllers\/Adminhtml<br>app\/code\/Webkul\/Grid\/view\/adminhtml\/layout<br>app\/code\/Webkul\/Grid\/view\/adminhtml\/templates<\/p>\n\n\n\n<p>Now, as we have the directory structure ready, we will now create file as per module requirement in given sequence:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.First, we have to create the module configuration file named module.xml in app\/code\/Webkul\/Grid\/etc<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;!--\n\/**\n * Webkul_Grid Module \n *\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\n *\/\n--&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Module\/etc\/module.xsd&quot;&gt;\n    &lt;module name=&quot;Webkul_Grid&quot; setup_version=&quot;2.0.0&quot;&gt;\n    &lt;\/module&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2.Then, we have to create the module registration\u00a0 file named registration.php in app\/code\/Webkul\/Grid<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n \/**\n * Webkul_Grid Module Registration\n *\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\n *\/\n\n\\Magento\\Framework\\Component\\ComponentRegistrar::register(\n    \\Magento\\Framework\\Component\\ComponentRegistrar::MODULE,\n    &#039;Webkul_Grid&#039;,\n    __DIR__\n);<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3.Now, we have to create the menu configuration file named menu.xml in app\/code\/Webkul\/Grid\/etc\/adminhtml<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;!--\n\/**\n * Webkul_Grid Menu\n *\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\n *\/\n--&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Backend:etc\/menu.xsd&quot;&gt;\n    &lt;menu&gt;\n    \t&lt;add id=&quot;Webkul_Grid::manager&quot; title=&quot;Grid Manager&quot; module=&quot;Webkul_Grid&quot; sortOrder=&quot;10&quot; resource=&quot;Webkul_Grid::manager&quot;\/&gt;\n    \t&lt;add id=&quot;Webkul_Grid::add_row&quot; title=&quot;Grid Manager&quot; module=&quot;Webkul_Grid&quot; sortOrder=&quot;20&quot; parent=&quot;Webkul_Grid::manager&quot; action=&quot;grid\/grid&quot; resource=&quot;Webkul_Grid::add_row&quot;\/&gt;\n    &lt;\/menu&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.Now, we have to create the Installer\u00a0 file named InstallSchema.php in app\/code\/Webkul\/Grid\/Setup.<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Grid Schema Setup.\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\/\nnamespace Webkul\\Grid\\Setup;\n\nuse Magento\\Framework\\Setup\\InstallSchemaInterface;\nuse Magento\\Framework\\Setup\\ModuleContextInterface;\nuse Magento\\Framework\\Setup\\SchemaSetupInterface;\n\n\/**\n * @codeCoverageIgnore\n *\/\nclass InstallSchema implements InstallSchemaInterface\n{\n    \/**\n     * {@inheritdoc}\n     *\n     * @SuppressWarnings(PHPMD.ExcessiveMethodLength)\n     *\/\n    public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)\n    {\n        $installer = $setup;\n\n        $installer-&gt;startSetup();\n\n        \/*\n         * Create table &#039;wk_grid_records&#039;\n         *\/\n\n        $table = $installer-&gt;getConnection()-&gt;newTable(\n            $installer-&gt;getTable(&#039;wk_grid_records&#039;)\n        )-&gt;addColumn(\n            &#039;entity_id&#039;,\n            \\Magento\\Framework\\DB\\Ddl\\Table::TYPE_INTEGER,\n            null,\n            &#091;&#039;identity&#039; =&gt; true, &#039;nullable&#039; =&gt; false, &#039;primary&#039; =&gt; true],\n            &#039;Grid Record Id&#039;\n        )-&gt;addColumn(\n            &#039;title&#039;,\n            \\Magento\\Framework\\DB\\Ddl\\Table::TYPE_TEXT,\n            255,\n            &#091;&#039;nullable&#039; =&gt; false],\n            &#039;Title&#039;\n        )-&gt;addColumn(\n            &#039;content&#039;,\n            \\Magento\\Framework\\DB\\Ddl\\Table::TYPE_TEXT,\n            &#039;2M&#039;,\n            &#091;&#039;nullable&#039; =&gt; false],\n            &#039;Post&#039;\n        )-&gt;addColumn(\n            &#039;publish_date&#039;,\n            \\Magento\\Framework\\DB\\Ddl\\Table::TYPE_DATE,\n            null,\n            &#091;],\n            &#039;Publish Date&#039;\n        )-&gt;addColumn(\n            &#039;is_active&#039;,\n            \\Magento\\Framework\\DB\\Ddl\\Table::TYPE_SMALLINT,\n            null,\n            &#091;],\n            &#039;Active Status&#039;\n        )-&gt;addColumn(\n            &#039;created_at&#039;,\n            \\Magento\\Framework\\DB\\Ddl\\Table::TYPE_TIMESTAMP,\n            &#091;&#039;nullable&#039; =&gt; false, &#039;default&#039; =&gt; \\Magento\\Framework\\DB\\Ddl\\Table::TIMESTAMP_INIT],\n            &#039;Creation Time&#039;\n        )-&gt;addColumn(\n            &#039;update_time&#039;,\n            \\Magento\\Framework\\DB\\Ddl\\Table::TYPE_TIMESTAMP,\n            &#091;&#039;nullable&#039; =&gt; false, &#039;default&#039; =&gt; \\Magento\\Framework\\DB\\Ddl\\Table::TIMESTAMP_INIT_UPDATE],\n            &#039;Modification Time&#039;\n        )-&gt;setComment(\n            &#039;Row Data Table&#039;\n        );\n\n        $installer-&gt;getConnection()-&gt;createTable($table);\n        $installer-&gt;endSetup();\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5.Now,\u00a0 for table \u2018wk_grid_records\u2019 which created by installer we have to create the Interface file named GridInterface.php in app\/code\/Webkul\/Grid\/Api\/Data .<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Software.\n *\n * @category   Webkul\n * @package    Webkul_Grid\n * @author     Webkul Software Private Limited\n * @copyright  Webkul Software Private Limited (https:\/\/webkul.com)\n * @license    https:\/\/store.webkul.com\/license.html\n *\/\nnamespace Webkul\\Grid\\Api\\Data;\n\n\/**\n * Grid Interface\n * @api\n *\/\ninterface GridInterface\n{\n    \/**#@+\n     * Constants for keys of data array. Identical to the name of the getter in snake case\n     *\/\n    public const ENTITY_ID          = &#039;entity_id&#039;;\n    public const TITLE              = &#039;title&#039;;\n    public const CONTENT            = &#039;content&#039;;\n    public const PUBLISH_DATE       = &#039;publish_date&#039;;\n    public const IS_ACTIVE          = &#039;is_active&#039;;\n    public const UPDATE_TIME        = &#039;update_time&#039;;\n    public const CREATED_AT         = &#039;created_at&#039;;\n\n\n    \/**\n     * Get Entity Id\n     *\n     * @return integer|null\n     *\/\n    public function getEntityId();\n\n    \/**\n     * Set Entity Id\n     *\n     * @param integer $entityId\n     * @return \\Webkul\\Grid\\Api\\Data\\GridInterface\n     *\/\n    public function setEntityId($entityId);\n\n    \/**\n     * Get Title\n     * @return \\Webkul\\Grid\\Api\\Data\\GridInterface\n     *\/\n    public function getTitle();\n\n    \/**\n     * Set Title\n     *\n     * @param string $title\n     * @return \\Webkul\\Grid\\Api\\Data\\GridInterface\n     *\/\n    public function setTitle($title);\n\n    \/**\n     * Get Content\n     *\n     * @return string|null\n     *\/\n    public function getContent();\n\n    \/**\n     * Set Content\n     *\n     * @param string $content\n     * @return \\Webkul\\Grid\\Api\\Data\\GridInterface\n     *\/\n    public function setContent($content);\n\n    \/**\n     * Get Publish Date\n     *\n     * @return string|null\n     *\/\n    public function getPublishDate();\n\n    \/**\n     * Set Publish Date\n     *\n     * @param string $publishDate\n     * @return \\Webkul\\Grid\\Api\\Data\\GridInterface\n     *\/\n    public function setPublishDate($publishDate);\n\n    \/**\n     * Get Is Active\n     *\n     * @return int|null\n     *\/\n    public function getIsActive();\n\n    \/**\n     * Set Is Active\n     *\n     * @param int $isActive\n     * @return \\Webkul\\Grid\\Api\\Data\\GridInterface\n     *\/\n    public function setIsActive($isActive);\n\n    \/**\n     * Get Update Time\n     *\n     * @return string|null\n     *\/\n    public function getUpdateTime();\n\n    \/**\n     * Set Update Time\n     *\n     * @param string $updateTime\n     * @return \\Webkul\\Grid\\Api\\Data\\GridInterface\n     *\/\n    public function setUpdateTime($updateTime);\n\n    \/**\n     * Get Created At\n     *\n     * @return string|null\n     *\/\n    public function getCreatedAt();\n\n    \/**\n     * Set Created At\n     *\n     * @param string $createdAt\n     * @return \\Webkul\\Grid\\Api\\Data\\GridInterface\n     *\/\n    public function setCreatedAt($createdAt);\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6.Now,\u00a0 we will implement the GridInterface in the Model file named Grid.php in app\/code\/Webkul\/Grid\/Model .<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Auction Grid Model.\n *\n * @category    Webkul\n *\n * @author      Webkul Software Private Limited\n *\/\nnamespace Webkul\\Grid\\Model;\n\nuse Webkul\\Grid\\Api\\Data\\GridInterface;\n\nclass Grid extends \\Magento\\Framework\\Model\\AbstractModel implements GridInterface\n{\n    \/**\n     * CMS page cache tag.\n     *\/\n    const CACHE_TAG = &#039;wk_grid_records&#039;;\n\n    \/**\n     * @var string\n     *\/\n    protected $_cacheTag = &#039;wk_grid_records&#039;;\n\n    \/**\n     * Prefix of model events names.\n     *\n     * @var string\n     *\/\n    protected $_eventPrefix = &#039;wk_grid_records&#039;;\n\n    \/**\n     * Initialize resource model.\n     *\/\n    protected function _construct()\n    {\n        $this-&gt;_init(&#039;Webkul\\Grid\\Model\\ResourceModel\\Grid&#039;);\n    }\n    \/**\n     * Get EntityId.\n     *\n     * @return int\n     *\/\n    public function getEntityId()\n    {\n        return $this-&gt;getData(self::ENTITY_ID);\n    }\n\n    \/**\n     * Set EntityId.\n     *\/\n    public function setEntityId($entityId)\n    {\n        return $this-&gt;setData(self::ENTITY_ID, $entityId);\n    }\n\n    \/**\n     * Get Title.\n     *\n     * @return varchar\n     *\/\n    public function getTitle()\n    {\n        return $this-&gt;getData(self::TITLE);\n    }\n\n    \/**\n     * Set Title.\n     *\/\n    public function setTitle($title)\n    {\n        return $this-&gt;setData(self::TITLE, $title);\n    }\n\n    \/**\n     * Get getContent.\n     *\n     * @return varchar\n     *\/\n    public function getContent()\n    {\n        return $this-&gt;getData(self::CONTENT);\n    }\n\n    \/**\n     * Set Content.\n     *\/\n    public function setContent($content)\n    {\n        return $this-&gt;setData(self::CONTENT, $content);\n    }\n\n    \/**\n     * Get PublishDate.\n     *\n     * @return varchar\n     *\/\n    public function getPublishDate()\n    {\n        return $this-&gt;getData(self::PUBLISH_DATE);\n    }\n\n    \/**\n     * Set PublishDate.\n     *\/\n    public function setPublishDate($publishDate)\n    {\n        return $this-&gt;setData(self::PUBLISH_DATE, $publishDate);\n    }\n\n    \/**\n     * Get IsActive.\n     *\n     * @return varchar\n     *\/\n    public function getIsActive()\n    {\n        return $this-&gt;getData(self::IS_ACTIVE);\n    }\n\n    \/**\n     * Set IsActive.\n     *\/\n    public function setIsActive($isActive)\n    {\n        return $this-&gt;setData(self::IS_ACTIVE, $isActive);\n    }\n\n    \/**\n     * Get UpdateTime.\n     *\n     * @return varchar\n     *\/\n    public function getUpdateTime()\n    {\n        return $this-&gt;getData(self::UPDATE_TIME);\n    }\n\n    \/**\n     * Set UpdateTime.\n     *\/\n    public function setUpdateTime($updateTime)\n    {\n        return $this-&gt;setData(self::UPDATE_TIME, $updateTime);\n    }\n\n    \/**\n     * Get CreatedAt.\n     *\n     * @return varchar\n     *\/\n    public function getCreatedAt()\n    {\n        return $this-&gt;getData(self::CREATED_AT);\n    }\n\n    \/**\n     * Set CreatedAt.\n     *\/\n    public function setCreatedAt($createdAt)\n    {\n        return $this-&gt;setData(self::CREATED_AT, $createdAt);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">7.Now,\u00a0 for table \u2018wk_grid_records\u2019 which created by installer we have to create the Resource\u00a0 Model\u00a0\u00a0 file named Grid.php in app\/code\/Webkul\/Grid\/Model\/ResourceModel.<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Grid Grid ResourceModel.\n * @category    Webkul\n * @author      Webkul Software Private Limited\n *\/\nnamespace Webkul\\Grid\\Model\\ResourceModel;\n\n\/**\n * Grid Grid mysql resource.\n *\/\nclass Grid extends \\Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb\n{\n    \/**\n     * @var string\n     *\/\n    protected $_idFieldName = &#039;entity_id&#039;;\n    \/**\n     * @var \\Magento\\Framework\\Stdlib\\DateTime\\DateTime\n     *\/\n    protected $_date;\n\n    \/**\n     * Construct.\n     *\n     * @param \\Magento\\Framework\\Model\\ResourceModel\\Db\\Context $context\n     * @param \\Magento\\Framework\\Stdlib\\DateTime\\DateTime       $date\n     * @param string|null                                       $resourcePrefix\n     *\/\n    public function __construct(\n        \\Magento\\Framework\\Model\\ResourceModel\\Db\\Context $context,\n        \\Magento\\Framework\\Stdlib\\DateTime\\DateTime $date,\n        $resourcePrefix = null\n    ) \n    {\n        parent::__construct($context, $resourcePrefix);\n        $this-&gt;_date = $date;\n    }\n\n    \/**\n     * Initialize resource model.\n     *\/\n    protected function _construct()\n    {\n        $this-&gt;_init(&#039;wk_grid_records&#039;, &#039;entity_id&#039;);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">8.Now,\u00a0 for table \u2018wk_grid_records\u2019 which created by installer we have to create the Collection file named Collection.php in app\/code\/Webkul\/Grid\/Model\/ResourceModel\/Grid.<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\n\/**\n * Grid Grid Collection.\n * @category    Webkul\n * @author      Webkul Software Private Limited\n *\/\nnamespace Webkul\\Grid\\Model\\ResourceModel\\Grid;\n\nclass Collection extends \\Magento\\Framework\\Model\\ResourceModel\\Db\\Collection\\AbstractCollection\n{\n    \/**\n     * @var string\n     *\/\n    protected $_idFieldName = &#039;entity_id&#039;;\n    \/**\n     * Define resource model.\n     *\/\n    protected function _construct()\n    {\n        $this-&gt;_init(&#039;Webkul\\Grid\\Model\\Grid&#039;, &#039;Webkul\\Grid\\Model\\ResourceModel\\Grid&#039;);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">9. After above steps now we will create ui component for grid row list. We&#8217;ll create grid_record_grid_list.xml in\u00a0 app\/code\/Webkul\/Grid\/view\/adminhtml\/ui_component folder as following.<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n&lt;!--\n    \/**\n     * Webkul Grid List UI\n     * @category    Webkul\n     * @package     Webkul_Grid\n     * @author      Webkul Software Private Limited\n     *\n     *\/\n --&gt;\n\n&lt;listing xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Ui\/etc\/ui_configuration.xsd&quot;&gt;\n    &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n        &lt;item name=&quot;js_config&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;provider&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list_data_source&lt;\/item&gt;\n            &lt;item name=&quot;deps&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list_data_source&lt;\/item&gt;\n        &lt;\/item&gt;\n        &lt;item name=&quot;spinner&quot; xsi:type=&quot;string&quot;&gt;webkul_grid_grid_columns&lt;\/item&gt;\n        &lt;item name=&quot;buttons&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;add&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;name&quot; xsi:type=&quot;string&quot;&gt;add&lt;\/item&gt;\n                &lt;item name=&quot;label&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Add New Row&lt;\/item&gt;\n                &lt;item name=&quot;class&quot; xsi:type=&quot;string&quot;&gt;primary&lt;\/item&gt;\n                &lt;item name=&quot;url&quot; xsi:type=&quot;string&quot;&gt;*\/*\/addrow&lt;\/item&gt;\n            &lt;\/item&gt;\n        &lt;\/item&gt;\n    &lt;\/argument&gt;\n    &lt;dataSource name=&quot;grid_record_grid_list_data_source&quot;&gt;\n        &lt;argument name=&quot;dataProvider&quot; xsi:type=&quot;configurableObject&quot;&gt;\n            &lt;argument name=&quot;class&quot; xsi:type=&quot;string&quot;&gt;PageGridDataProvider&lt;\/argument&gt;\n            &lt;!-- here we pass dataprovider name which i will define in di.xml file of module in next step --&gt;\n            &lt;argument name=&quot;name&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list_data_source&lt;\/argument&gt;\n            &lt;argument name=&quot;primaryFieldName&quot; xsi:type=&quot;string&quot;&gt;id&lt;\/argument&gt;\n            &lt;argument name=&quot;requestFieldName&quot; xsi:type=&quot;string&quot;&gt;id&lt;\/argument&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;update_url&quot; xsi:type=&quot;url&quot; path=&quot;mui\/index\/render&quot;\/&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/argument&gt;\n        &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;js_config&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/provider&lt;\/item&gt;\n            &lt;\/item&gt;\n        &lt;\/argument&gt;\n    &lt;\/dataSource&gt;\n    &lt;container name=&quot;listing_top&quot;&gt;\n        &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;template&quot; xsi:type=&quot;string&quot;&gt;ui\/grid\/toolbar&lt;\/item&gt;\n                &lt;item name=&quot;stickyTmpl&quot; xsi:type=&quot;string&quot;&gt;ui\/grid\/sticky\/toolbar&lt;\/item&gt;\n            &lt;\/item&gt;\n        &lt;\/argument&gt;\n        &lt;component name=&quot;columns_controls&quot;&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;columnsData&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;provider&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list.webkul_grid_grid_columns&lt;\/item&gt;\n                    &lt;\/item&gt;\n                    &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/controls\/columns&lt;\/item&gt;\n                    &lt;item name=&quot;displayArea&quot; xsi:type=&quot;string&quot;&gt;dataGridActions&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/component&gt;\n        &lt;filters name=&quot;listing_filters&quot;&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;columnsProvider&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list.webkul_grid_grid_columns&lt;\/item&gt;\n                    &lt;item name=&quot;storageConfig&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;provider&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list.listing_top.bookmarks&lt;\/item&gt;\n                        &lt;item name=&quot;namespace&quot; xsi:type=&quot;string&quot;&gt;current.filters&lt;\/item&gt;\n                    &lt;\/item&gt;\n                    &lt;item name=&quot;templates&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;filters&quot; xsi:type=&quot;array&quot;&gt;\n                            &lt;item name=&quot;select&quot; xsi:type=&quot;array&quot;&gt;\n                                &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/form\/element\/ui-select&lt;\/item&gt;\n                                &lt;item name=&quot;template&quot; xsi:type=&quot;string&quot;&gt;ui\/grid\/filters\/elements\/ui-select&lt;\/item&gt;\n                            &lt;\/item&gt;\n                        &lt;\/item&gt;\n                    &lt;\/item&gt;\n                    &lt;item name=&quot;childDefaults&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;provider&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list.listing_top.listing_filters&lt;\/item&gt;\n                        &lt;item name=&quot;imports&quot; xsi:type=&quot;array&quot;&gt;\n                            &lt;item name=&quot;visible&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list.webkul_grid_grid_columns.${ $.index }:visible&lt;\/item&gt;\n                        &lt;\/item&gt;\n                    &lt;\/item&gt;\n                &lt;\/item&gt;\n                &lt;item name=&quot;observers&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;column&quot; xsi:type=&quot;string&quot;&gt;column&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/filters&gt;\n        &lt;massaction name=&quot;listing_massaction&quot;&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;selectProvider&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list.webkul_grid_grid_columns.ids&lt;\/item&gt;\n                    &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/tree-massactions&lt;\/item&gt;\n                    &lt;item name=&quot;indexField&quot; xsi:type=&quot;string&quot;&gt;id&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n            &lt;!-- Mass actions which you want to add in your grid--&gt;\n            &lt;action name=&quot;delete&quot;&gt;\n                &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;type&quot; xsi:type=&quot;string&quot;&gt;delete&lt;\/item&gt;\n                        &lt;item name=&quot;label&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Delete&lt;\/item&gt;\n                        &lt;item name=&quot;url&quot; xsi:type=&quot;url&quot; path=&quot;grid\/grid\/massdelete&quot;\/&gt;\n                        &lt;item name=&quot;confirm&quot; xsi:type=&quot;array&quot;&gt;\n                            &lt;item name=&quot;title&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Delete&lt;\/item&gt;\n                            &lt;item name=&quot;message&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Do you want to delete selected row record?&lt;\/item&gt;\n                        &lt;\/item&gt;\n                    &lt;\/item&gt;\n                &lt;\/argument&gt;\n            &lt;\/action&gt;\n        &lt;\/massaction&gt;\n        &lt;paging name=&quot;listing_paging&quot;&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;storageConfig&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;provider&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list.listing_top.bookmarks&lt;\/item&gt;\n                        &lt;item name=&quot;namespace&quot; xsi:type=&quot;string&quot;&gt;current.paging&lt;\/item&gt;\n                    &lt;\/item&gt;\n                    &lt;item name=&quot;selectProvider&quot; xsi:type=&quot;string&quot;&gt;grid_record_grid_list.grid_record_grid_list.webkul_grid_grid_columns.ids&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/paging&gt;\n    &lt;\/container&gt;\n    &lt;!-- from here we&#039;ll add columns of grid list --&gt;\n    &lt;columns name=&quot;webkul_grid_grid_columns&quot;&gt;\n         &lt;selectionsColumn name=&quot;ids&quot;&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;indexField&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/item&gt;\n                    &lt;item name=&quot;sorting&quot; xsi:type=&quot;string&quot;&gt;desc&lt;\/item&gt;\n                    &lt;item name=&quot;sortOrder&quot; xsi:type=&quot;number&quot;&gt;0&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/selectionsColumn&gt;\n        &lt;column name=&quot;title&quot;&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;filter&quot; xsi:type=&quot;string&quot;&gt;textRange&lt;\/item&gt;\n                    &lt;item name=&quot;label&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Title&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;content&quot; &gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;filter&quot; xsi:type=&quot;string&quot;&gt;false&lt;\/item&gt;\n                    &lt;item name=&quot;label&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Content&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;is_active&quot; &gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;options&quot; xsi:type=&quot;object&quot;&gt;Webkul\\Grid\\Model\\Status&lt;\/item&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;filter&quot; xsi:type=&quot;string&quot;&gt;select&lt;\/item&gt;\n                    &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/columns\/select&lt;\/item&gt;\n                    &lt;item name=&quot;dataType&quot; xsi:type=&quot;string&quot;&gt;select&lt;\/item&gt;\n                    &lt;item name=&quot;label&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Is Active&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;publish_date&quot; class=&quot;Magento\\Ui\\Component\\Listing\\Columns\\Date&quot; &gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;filter&quot; xsi:type=&quot;string&quot;&gt;dateRange&lt;\/item&gt;\n                    &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/columns\/date&lt;\/item&gt;\n                    &lt;item name=&quot;dataType&quot; xsi:type=&quot;string&quot;&gt;date&lt;\/item&gt;\n                    &lt;item name=&quot;label&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Publish Date&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;update_time&quot; class=&quot;Magento\\Ui\\Component\\Listing\\Columns\\Date&quot; &gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;filter&quot; xsi:type=&quot;string&quot;&gt;dateRange&lt;\/item&gt;\n                    &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/columns\/date&lt;\/item&gt;\n                    &lt;item name=&quot;dataType&quot; xsi:type=&quot;string&quot;&gt;date&lt;\/item&gt;\n                    &lt;item name=&quot;label&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Update Time&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;created_at&quot; class=&quot;Magento\\Ui\\Component\\Listing\\Columns\\Date&quot; &gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;filter&quot; xsi:type=&quot;string&quot;&gt;dateRange&lt;\/item&gt;\n                    &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/columns\/date&lt;\/item&gt;\n                    &lt;item name=&quot;dataType&quot; xsi:type=&quot;string&quot;&gt;date&lt;\/item&gt;\n                    &lt;item name=&quot;label&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Created At&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/column&gt; \n        &lt;!-- Add Action with each row of grid and for this we will create a class Action --&gt;\n        &lt;actionsColumn name=&quot;actions&quot; class=&quot;Webkul\\Grid\\Ui\\Component\\Listing\\Grid\\Column\\Action&quot;&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;resizeEnabled&quot; xsi:type=&quot;boolean&quot;&gt;false&lt;\/item&gt;\n                    &lt;item name=&quot;resizeDefaultWidth&quot; xsi:type=&quot;string&quot;&gt;107&lt;\/item&gt;\n                    &lt;item name=&quot;indexField&quot; xsi:type=&quot;string&quot;&gt;id&lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/actionsColumn&gt;\n    &lt;\/columns&gt;\n&lt;\/listing&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">10. create di.xml file for map data provider with collection in app\/code\/Webkul\/Grid\/etc.<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;!--\n    \/**\n     * Webkul Grid DI\n     *\n     * @category    Webkul\n     * @package     Webkul_Grid\n     * @author      Webkul Software Private Limited\n     *\n     *\/\n --&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager\/etc\/config.xsd&quot;&gt;\n     &lt;virtualType name=&quot;Webkul\\Grid\\Model\\ResourceModel\\Grid\\Grid\\Collection&quot; type=&quot;Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\SearchResult&quot;&gt;\n        &lt;arguments&gt;\n            &lt;argument name=&quot;mainTable&quot; xsi:type=&quot;string&quot;&gt;wk_grid_records&lt;\/argument&gt;\n            &lt;argument name=&quot;resourceModel&quot; xsi:type=&quot;string&quot;&gt;Webkul\\Grid\\Model\\ResourceModel\\Grid&lt;\/argument&gt;\n        &lt;\/arguments&gt;\n    &lt;\/virtualType&gt;\n    &lt;type name=&quot;Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\CollectionFactory&quot;&gt;\n        &lt;arguments&gt;\n            &lt;argument name=&quot;collections&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;!--data provider name which used in grid ui component file --&gt;\n                &lt;item name=&quot;grid_record_grid_list_data_source&quot; xsi:type=&quot;string&quot;&gt;Webkul\\Grid\\Model\\ResourceModel\\Grid\\Grid\\Collection&lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/arguments&gt;\n    &lt;\/type&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">11. For action we will create Action Class Action.php in app\/code\/Webkul\/Grid\/Ui\/Component\/Listing\/Grid\/Column<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\nnamespace Webkul\\Grid\\Ui\\Component\\Listing\\Grid\\Column;\n\nuse Magento\\Framework\\View\\Element\\UiComponent\\ContextInterface;\nuse Magento\\Framework\\View\\Element\\UiComponentFactory;\nuse Magento\\Ui\\Component\\Listing\\Columns\\Column;\nuse Magento\\Framework\\UrlInterface;\n\nclass Action extends Column\n{\n    \/** Url path *\/\n    const ROW_EDIT_URL = &#039;grid\/grid\/addrow&#039;;\n    \/** @var UrlInterface *\/\n    protected $_urlBuilder;\n\n    \/**\n     * @var string\n     *\/\n    private $_editUrl;\n\n    \/**\n     * @param ContextInterface   $context\n     * @param UiComponentFactory $uiComponentFactory\n     * @param UrlInterface       $urlBuilder\n     * @param array              $components\n     * @param array              $data\n     * @param string             $editUrl\n     *\/\n    public function __construct(\n        ContextInterface $context,\n        UiComponentFactory $uiComponentFactory,\n        UrlInterface $urlBuilder,\n        array $components = &#091;],\n        array $data = &#091;],\n        $editUrl = self::ROW_EDIT_URL\n    ) \n    {\n        $this-&gt;_urlBuilder = $urlBuilder;\n        $this-&gt;_editUrl = $editUrl;\n        parent::__construct($context, $uiComponentFactory, $components, $data);\n    }\n\n    \/**\n     * Prepare Data Source.\n     *\n     * @param array $dataSource\n     *\n     * @return array\n     *\/\n    public function prepareDataSource(array $dataSource)\n    {\n        if (isset($dataSource&#091;&#039;data&#039;]&#091;&#039;items&#039;])) {\n            foreach ($dataSource&#091;&#039;data&#039;]&#091;&#039;items&#039;] as &amp;$item) {\n                $name = $this-&gt;getData(&#039;name&#039;);\n                if (isset($item&#091;&#039;entity_id&#039;])) {\n                    $item&#091;$name]&#091;&#039;edit&#039;] = &#091;\n                        &#039;href&#039; =&gt; $this-&gt;_urlBuilder-&gt;getUrl(\n                            $this-&gt;_editUrl, \n                            &#091;&#039;id&#039; =&gt; $item&#091;&#039;entity_id&#039;]]\n                        ),\n                        &#039;label&#039; =&gt; __(&#039;Edit&#039;),\n                    ];\n                }\n            }\n        }\n\n        return $dataSource;\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">12. Our UI component and data provider become ready . now we will create controller file index.php in app\/code\/Webkul\/Grid\/Controller\/Adminhtml\/Grid<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Grid Controller\n *\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\n *\/\nnamespace Webkul\\Grid\\Controller\\Adminhtml\\Grid;\n\nclass Index extends \\Magento\\Backend\\App\\Action\n{\n    \/**\n     * @var \\Magento\\Framework\\View\\Result\\PageFactory\n     *\/\n    protected $_resultPageFactory;\n\n    \/**\n     * @param \\Magento\\Backend\\App\\Action\\Context        $context\n     * @param \\Magento\\Framework\\View\\Result\\PageFactory $resultPageFactory\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\App\\Action\\Context $context,\n        \\Magento\\Framework\\View\\Result\\PageFactory $resultPageFactory\n    ) \n    {\n        parent::__construct($context);\n        $this-&gt;_resultPageFactory = $resultPageFactory;\n    }\n\n    \/**\n     * Grid List page.\n     *\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Page\n     *\/\n    public function execute()\n    {\n        \/** @var \\Magento\\Backend\\Model\\View\\Result\\Page $resultPage *\/\n        $resultPage = $this-&gt;_resultPageFactory-&gt;create();\n        $resultPage-&gt;setActiveMenu(&#039;Webkul_Grid::grid_list&#039;);\n        $resultPage-&gt;getConfig()-&gt;getTitle()-&gt;prepend(__(&#039;Grid List&#039;));\n\n        return $resultPage;\n    }\n\n    \/**\n     * Check Grid List Permission.\n     *\n     * @return bool\n     *\/\n    protected function _isAllowed()\n    {\n        return $this-&gt;_authorization-&gt;isAllowed(&#039;Webkul_Grid::grid_list&#039;);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">13. Create route file routes.xml in app\/code\/Webkul\/Grid\/etc\/adminhtml<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;!--\n\/**\n * Webkul_Grid route xml\n *\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\n *\/\n--&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:App\/etc\/routes.xsd&quot;&gt;\n    &lt;router id=&quot;admin&quot;&gt;\n        &lt;route id=&quot;grid&quot; frontName=&quot;grid&quot;&gt;\n            &lt;module name=&quot;Webkul_grid&quot; \/&gt;\n        &lt;\/route&gt;\n    &lt;\/router&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">14. And for grid display create layout file grid_grid_index.xml in app\/code\/Webkul\/Grid\/view\/adminhtml\/layout<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;!--\n\/**\n * Webkul Grid Grid List Layout\n *\n * @category    Webkul\n * @package     Webkul_Grib\n * @author      Webkul Software Private Limited\n *\n *\/\n--&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n    &lt;body&gt;\n        &lt;referenceContainer name=&quot;content&quot;&gt;\n                &lt;!-- here we call our ui component of grid--&gt;\n        \t&lt;uiComponent name=&quot;grid_record_grid_list&quot;\/&gt;\n        &lt;\/referenceContainer&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">15. Above i missed one model of status so now i will create Status.php in app\/code\/Webkul\/Grid\/Model<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul_Grid Status Options Model.\n * @category    Webkul\n * @author      Webkul Software Private Limited\n *\/\nnamespace Webkul\\Grid\\Model;\nuse Magento\\Framework\\Data\\OptionSourceInterface;\n\nclass Status implements OptionSourceInterface\n{\n    \/**\n     * Get Grid row status type labels array.\n     * @return array\n     *\/\n    public function getOptionArray()\n    {\n        $options = &#091;&#039;1&#039; =&gt; __(&#039;Enabled&#039;),&#039;0&#039; =&gt; __(&#039;Disabled&#039;)];\n        return $options;\n    }\n\n    \/**\n     * Get Grid row status labels array with empty value for option element.\n     *\n     * @return array\n     *\/\n    public function getAllOptions()\n    {\n        $res = $this-&gt;getOptions();\n        array_unshift($res, &#091;&#039;value&#039; =&gt; &#039;&#039;, &#039;label&#039; =&gt; &#039;&#039;]);\n        return $res;\n    }\n\n    \/**\n     * Get Grid row type array for option element.\n     * @return array\n     *\/\n    public function getOptions()\n    {\n        $res = &#091;];\n        foreach ($this-&gt;getOptionArray() as $index =&gt; $value) {\n            $res&#091;] = &#091;&#039;value&#039; =&gt; $index, &#039;label&#039; =&gt; $value];\n        }\n        return $res;\n    }\n\n    \/**\n     * {@inheritdoc}\n     *\/\n    public function toOptionArray()\n    {\n        return $this-&gt;getOptions();\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">16. After these all our grid ready in admin section as follow<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1277\" height=\"669\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_063-3.png\" alt=\"Selection_063\" class=\"wp-image-48541\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_063-3.png 1277w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_063-3-250x131.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_063-3-300x157.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_063-3-768x402.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_063-3-1200x629.png 1200w\" sizes=\"(max-width: 1277px) 100vw, 1277px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">17. Now we&#8217;ll start how to save\/edit&nbsp; data in table using form<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Above in our Ui component file\u00a0 grid_record_grid_list.xml we already add path of add form url now we&#8217;ll create controller file AddRow.php in app\/code\/Webkul\/Grid\/Controller\/Adminhtml\/Grid<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Grid AddRow Controller\n *\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\n *\/\nnamespace Webkul\\Grid\\Controller\\Adminhtml\\Grid;\n\nuse Magento\\Framework\\Controller\\ResultFactory;\n\nclass AddRow extends \\Magento\\Backend\\App\\Action\n{\n    \/**\n     * @param \\Magento\\Backend\\App\\Action\\Context $context\n     * @param \\Magento\\Framework\\Registry    $coreRegistry\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\App\\Action\\Context $context,\n        \\Magento\\Framework\\Registry $coreRegistry\n    ) \n    {\n        parent::__construct($context);\n        $this-&gt;_coreRegistry = $coreRegistry;\n    }\n    \/**\n     * Add New Row Form page.\n     *\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Page\n     *\/\n    public function execute()\n    {\n        $rowId = (int) $this-&gt;getRequest()-&gt;getParam(&#039;id&#039;);\n        $rowData = $this-&gt;_objectManager-&gt;create(&#039;Webkul\\Grid\\Model\\Grid&#039;);\n        if ($rowId) {\n            $rowData = $rowData-&gt;load($rowId);\n            $rowTitle = $rowData-&gt;getTitle();\n            if (!$rowData-&gt;getEntityId()) {\n                $this-&gt;messageManager-&gt;addError(__(&#039;row data no longer exist.&#039;));\n                $this-&gt;_redirect(&#039;grid\/grid\/rowdata&#039;);\n                return;\n            }\n        }\n\n        $this-&gt;_coreRegistry-&gt;register(&#039;row_data&#039;, $rowData);\n        $resultPage = $this-&gt;resultFactory-&gt;create(ResultFactory::TYPE_PAGE);\n        $title = $rowId ? __(&#039;Edit Row Data &#039;).$rowTitle : __(&#039;Add Row Data&#039;);\n        $resultPage-&gt;getConfig()-&gt;getTitle()-&gt;prepend($title);\n        return $resultPage;\n    }\n    protected function _isAllowed()\n    {\n        return $this-&gt;_authorization-&gt;isAllowed(&#039;Webkul_Grid::add_row&#039;);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">18. Create block file of form AddRow.php in app\/code\/Webkul\/Grid\/Block\/Adminhtml\/Grid<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n    \/**\n     * Webkul_Grid Add Row Form Block.\n     *\n     * @category    Webkul\n     *\n     * @author      Webkul Software Private Limited\n     *\/\nnamespace Webkul\\Grid\\Block\\Adminhtml\\Grid;\n\nclass AddRow extends \\Magento\\Backend\\Block\\Widget\\Form\\Container\n{\n    \/**\n     * Core registry.\n     *\n     * @var \\Magento\\Framework\\Registry\n     *\/\n    protected $_coreRegistry = null;\n\n    \/**\n     * @param \\Magento\\Backend\\Block\\Widget\\Context $context\n     * @param \\Magento\\Framework\\Registry           $registry\n     * @param array                                 $data\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\Block\\Widget\\Context $context,\n        \\Magento\\Framework\\Registry $registry,\n        array $data = &#091;]\n    ) \n    {\n        $this-&gt;_coreRegistry = $registry;\n        parent::__construct($context, $data);\n    }\n\n    \/**\n     * Initialize Imagegallery Images Edit Block.\n     *\/\n    protected function _construct()\n    {\n        $this-&gt;_objectId = &#039;row_id&#039;;\n        $this-&gt;_blockGroup = &#039;Webkul_Grid&#039;;\n        $this-&gt;_controller = &#039;adminhtml_grid&#039;;\n        parent::_construct();\n        if ($this-&gt;_isAllowedAction(&#039;Webkul_Grid::add_row&#039;)) {\n            $this-&gt;buttonList-&gt;update(&#039;save&#039;, &#039;label&#039;, __(&#039;Save&#039;));\n        } else {\n            $this-&gt;buttonList-&gt;remove(&#039;save&#039;);\n        }\n        $this-&gt;buttonList-&gt;remove(&#039;reset&#039;);\n    }\n\n    \/**\n     * Retrieve text for header element depending on loaded image.\n     *\n     * @return \\Magento\\Framework\\Phrase\n     *\/\n    public function getHeaderText()\n    {\n        return __(&#039;Add RoW Data&#039;);\n    }\n\n    \/**\n     * Check permission for passed action.\n     *\n     * @param string $resourceId\n     *\n     * @return bool\n     *\/\n    protected function _isAllowedAction($resourceId)\n    {\n        return $this-&gt;_authorization-&gt;isAllowed($resourceId);\n    }\n\n    \/**\n     * Get form action URL.\n     *\n     * @return string\n     *\/\n    public function getFormActionUrl()\n    {\n        if ($this-&gt;hasFormActionUrl()) {\n            return $this-&gt;getData(&#039;form_action_url&#039;);\n        }\n\n        return $this-&gt;getUrl(&#039;*\/*\/save&#039;);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">19. Create block file of form with field\u00a0 Form.php in app\/code\/Webkul\/Grid\/Block\/Adminhtml\/Grid\/Edit<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul_Grid Add New Row Form Admin Block.\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\n *\/\nnamespace Webkul\\Grid\\Block\\Adminhtml\\Grid\\Edit;\n\n\n\/**\n * Adminhtml Add New Row Form.\n *\/\nclass Form extends \\Magento\\Backend\\Block\\Widget\\Form\\Generic\n{\n    \/**\n     * @var \\Magento\\Store\\Model\\System\\Store\n     *\/\n    protected $_systemStore;\n\n    \/**\n     * @param \\Magento\\Backend\\Block\\Template\\Context $context\n     * @param \\Magento\\Framework\\Registry             $registry\n     * @param \\Magento\\Framework\\Data\\FormFactory     $formFactory\n     * @param array                                   $data\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\Block\\Template\\Context $context,\n        \\Magento\\Framework\\Registry $registry,\n        \\Magento\\Framework\\Data\\FormFactory $formFactory,\n        \\Magento\\Cms\\Model\\Wysiwyg\\Config $wysiwygConfig,\n        \\Webkul\\Grid\\Model\\Status $options,\n        array $data = &#091;]\n    ) \n    {\n        $this-&gt;_options = $options;\n        $this-&gt;_wysiwygConfig = $wysiwygConfig;\n        parent::__construct($context, $registry, $formFactory, $data);\n    }\n\n    \/**\n     * Prepare form.\n     *\n     * @return $this\n     *\/\n    protected function _prepareForm()\n    {\n        $dateFormat = $this-&gt;_localeDate-&gt;getDateFormat(\\IntlDateFormatter::SHORT);\n        $model = $this-&gt;_coreRegistry-&gt;registry(&#039;row_data&#039;);\n        $form = $this-&gt;_formFactory-&gt;create(\n            &#091;&#039;data&#039; =&gt; &#091;\n                            &#039;id&#039; =&gt; &#039;edit_form&#039;, \n                            &#039;enctype&#039; =&gt; &#039;multipart\/form-data&#039;, \n                            &#039;action&#039; =&gt; $this-&gt;getData(&#039;action&#039;), \n                            &#039;method&#039; =&gt; &#039;post&#039;\n                        ]\n            ]\n        );\n\n        $form-&gt;setHtmlIdPrefix(&#039;wkgrid_&#039;);\n        if ($model-&gt;getEntityId()) {\n            $fieldset = $form-&gt;addFieldset(\n                &#039;base_fieldset&#039;,\n                &#091;&#039;legend&#039; =&gt; __(&#039;Edit Row Data&#039;), &#039;class&#039; =&gt; &#039;fieldset-wide&#039;]\n            );\n            $fieldset-&gt;addField(&#039;entity_id&#039;, &#039;hidden&#039;, &#091;&#039;name&#039; =&gt; &#039;entity_id&#039;]);\n        } else {\n            $fieldset = $form-&gt;addFieldset(\n                &#039;base_fieldset&#039;,\n                &#091;&#039;legend&#039; =&gt; __(&#039;Add Row Data&#039;), &#039;class&#039; =&gt; &#039;fieldset-wide&#039;]\n            );\n        }\n\n        $fieldset-&gt;addField(\n            &#039;title&#039;,\n            &#039;text&#039;,\n            &#091;\n                &#039;name&#039; =&gt; &#039;title&#039;,\n                &#039;label&#039; =&gt; __(&#039;Title&#039;),\n                &#039;id&#039; =&gt; &#039;title&#039;,\n                &#039;title&#039; =&gt; __(&#039;Title&#039;),\n                &#039;class&#039; =&gt; &#039;required-entry&#039;,\n                &#039;required&#039; =&gt; true,\n            ]\n        );\n\n        $wysiwygConfig = $this-&gt;_wysiwygConfig-&gt;getConfig(&#091;&#039;tab_id&#039; =&gt; $this-&gt;getTabId()]);\n\n        $fieldset-&gt;addField(\n            &#039;content&#039;,\n            &#039;editor&#039;,\n            &#091;\n                &#039;name&#039; =&gt; &#039;content&#039;,\n                &#039;label&#039; =&gt; __(&#039;Content&#039;),\n                &#039;style&#039; =&gt; &#039;height:36em;&#039;,\n                &#039;required&#039; =&gt; true,\n                &#039;config&#039; =&gt; $wysiwygConfig\n            ]\n        );\n\n        $fieldset-&gt;addField(\n            &#039;publish_date&#039;,\n            &#039;date&#039;,\n            &#091;\n                &#039;name&#039; =&gt; &#039;publish_date&#039;,\n                &#039;label&#039; =&gt; __(&#039;Publish Date&#039;),\n                &#039;date_format&#039; =&gt; $dateFormat,\n                &#039;time_format&#039; =&gt; &#039;HH:mm:ss TT&#039;,\n                &#039;class&#039; =&gt; &#039;validate-date validate-date-range date-range-custom_theme-from&#039;,\n                &#039;class&#039; =&gt; &#039;required-entry&#039;,\n                &#039;style&#039; =&gt; &#039;width:200px&#039;,\n            ]\n        );\n        $fieldset-&gt;addField(\n            &#039;is_active&#039;,\n            &#039;select&#039;,\n            &#091;\n                &#039;name&#039; =&gt; &#039;is_active&#039;,\n                &#039;label&#039; =&gt; __(&#039;Status&#039;),\n                &#039;id&#039; =&gt; &#039;is_active&#039;,\n                &#039;title&#039; =&gt; __(&#039;Status&#039;),\n                &#039;values&#039; =&gt; $this-&gt;_options-&gt;getOptionArray(),\n                &#039;class&#039; =&gt; &#039;status&#039;,\n                &#039;required&#039; =&gt; true,\n            ]\n        );\n        $form-&gt;setValues($model-&gt;getData());\n        $form-&gt;setUseContainer(true);\n        $this-&gt;setForm($form);\n\n        return parent::_prepareForm();\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">20. For render this form create layout file grid_grid_addrow.xml in app\/code\/Webkul\/Grid\/view\/adminhtml\/layout<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;!--\n\/**\n * Webkul_Grid add row layout\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\/\n--&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; layout=&quot;admin-1column&quot;\n      xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n    &lt;head&gt;\n        &lt;link src=&quot;Magento_Customer::js\/bootstrap\/customer-post-action.js&quot;\/&gt;\n    &lt;\/head&gt;\n    &lt;body&gt;\n        &lt;referenceContainer name=&quot;content&quot;&gt;\n           &lt;block class=&quot;Webkul\\Grid\\Block\\Adminhtml\\Grid\\AddRow&quot; name=&quot;add_row&quot; \/&gt;\n        &lt;\/referenceContainer&gt;\n    &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">21. Now when we create on &#8220;Add New Row&#8221; Button on grid then form will open as follow<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1290\" height=\"674\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_064.png\" alt=\"Selection_064\" class=\"wp-image-48547\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_064.png 1290w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_064-250x131.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_064-300x157.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_064-768x401.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_064-1200x627.png 1200w\" sizes=\"(max-width: 1290px) 100vw, 1290px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">22. Create\u00a0 controller Save.php in app\/code\/Webkul\/Grid\/Controller\/Adminhtml\/Grid for save record<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Grid Row Save Controller\n *\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\n *\/\nnamespace Webkul\\Grid\\Controller\\Adminhtml\\Grid;\n\nclass Save extends \\Magento\\Backend\\App\\Action\n{\n    \/**\n     * @SuppressWarnings(PHPMD.CyclomaticComplexity)\n     * @SuppressWarnings(PHPMD.NPathComplexity)\n     *\/\n    public function execute()\n    {\n        $data = $this-&gt;getRequest()-&gt;getPostValue();\n        if (!$data) {\n            $this-&gt;_redirect(&#039;grid\/grid\/addrow&#039;);\n            return;\n        }\n        try {\n            $rowData = $this-&gt;_objectManager-&gt;create(&#039;Webkul\\Grid\\Model\\Grid&#039;);\n            $rowData-&gt;setData($data);\n            if (isset($data&#091;&#039;id&#039;])) {\n                $rowData-&gt;setEntityId($data&#091;&#039;id&#039;]);\n            }\n            $rowData-&gt;save();\n            $this-&gt;messageManager-&gt;addSuccess(__(&#039;Row data has been successfully saved.&#039;));\n        } catch (Exception $e) {\n            $this-&gt;messageManager-&gt;addError(__($e-&gt;getMessage()));\n        }\n        $this-&gt;_redirect(&#039;grid\/grid\/index&#039;);\n    }\n\n    \/**\n     * Check Category Map permission.\n     *\n     * @return bool\n     *\/\n    protected function _isAllowed()\n    {\n        return $this-&gt;_authorization-&gt;isAllowed(&#039;Webkul_Auction::add_auction&#039;);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">23. After save row data it will display in grid as follow<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1286\" height=\"621\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_065.png\" alt=\"Selection_065\" class=\"wp-image-48550\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_065.png 1286w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_065-250x121.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_065-300x145.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_065-768x371.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_065-1200x579.png 1200w\" sizes=\"(max-width: 1286px) 100vw, 1286px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">24. Now we create controller for mass delete MassDelete.php in app\/code\/Webkul\/Grid\/Controller\/Adminhtml\/Grid<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Grid Row MassDelete Controller\n *\n * @category    Webkul\n * @package     Webkul_Grid\n * @author      Webkul Software Private Limited\n *\n *\/\nnamespace Webkul\\Grid\\Controller\\Adminhtml\\Grid;\n\nuse Magento\\Framework\\Controller\\ResultFactory;\nuse Magento\\Backend\\App\\Action\\Context;\nuse Magento\\Ui\\Component\\MassAction\\Filter;\nuse Webkul\\Grid\\Model\\ResourceModel\\Grid\\CollectionFactory;\n\nclass MassDelete extends \\Magento\\Backend\\App\\Action\n{\n    \/**\n     * Massactions filter.\n     *\n     * @var Filter\n     *\/\n    protected $_filter;\n\n    \/**\n     * @var CollectionFactory\n     *\/\n    protected $_collectionFactory;\n\n    \/**\n     * @param Context           $context\n     * @param Filter            $filter\n     * @param CollectionFactory $collectionFactory\n     *\/\n    public function __construct(\n        Context $context,\n        Filter $filter,\n        CollectionFactory $collectionFactory\n    ) \n    {\n        $this-&gt;_filter = $filter;\n        $this-&gt;_collectionFactory = $collectionFactory;\n        parent::__construct($context);\n    }\n\n    \/**\n     * @return \\Magento\\Backend\\Model\\View\\Result\\Redirect\n     *\/\n    public function execute()\n    {\n        $collection = $this-&gt;_filter-&gt;getCollection($this-&gt;_collectionFactory-&gt;create());\n        $recordDeleted = 0;\n        foreach ($collection-&gt;getItems() as $auctionProduct) {\n            $auctionProduct-&gt;setId($auctionProduct-&gt;getEntityId());\n            $auctionProduct-&gt;delete();\n            $recordDeleted++;\n        }\n        $this-&gt;messageManager-&gt;addSuccess(\n            __(&#039;A total of %1 record(s) have been deleted.&#039;, $recordDeleted)\n        );\n\n        return $this-&gt;resultFactory-&gt;create(ResultFactory::TYPE_REDIRECT)-&gt;setPath(&#039;*\/*\/index&#039;);\n    }\n\n    \/**\n     * Check delete Permission.\n     *\n     * @return bool\n     *\/\n    protected function _isAllowed()\n    {\n        return $this-&gt;_authorization-&gt;isAllowed(&#039;Webkul_Grid::row_data_delete&#039;);\n    }\n}<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">25. After that you can delete row form grid as<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1286\" height=\"608\" src=\"http:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_066.png\" alt=\"Selection_066\" class=\"wp-image-48552\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_066.png 1286w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_066-250x118.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_066-300x142.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_066-768x363.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Selection_066-1200x567.png 1200w\" sizes=\"(max-width: 1286px) 100vw, 1286px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Now Create grid, insert, Edit, and update (Magento2 admin grid data CRUD ) feature done.<\/p>\n\n\n\n<p>Also, do check out <a href=\"https:\/\/store.webkul.com\/Magento2-Custom-Registration-Field.html\">Custom Registration Fields for Magento 2 extension<\/a> where the admin can effortlessly create various custom fields.<\/p>\n\n\n\n<p>Thanks \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here we create Collection Grid , edit\/add grid row and installer in Magento2 Before starting the code section, let us create the directory structure that we will need for create admin grid edit\/add grid row and installer. app\/code\/Webkul\/Gridapp\/code\/Webkul\/Grid\/etcapp\/code\/Webkul\/Grid\/etc\/Adminhtmlapp\/code\/Webkul\/Grid\/Block\/Adminhtmlapp\/code\/Webkul\/Grid\/Block\/Adminhtml\/Gridapp\/code\/Webkul\/Grid\/Block\/Adminhtml\/Grid\/Editapp\/code\/Webkul\/Grid\/Modelapp\/code\/Webkul\/Grid\/Model\/ResourceModelapp\/code\/Webkul\/Grid\/Model\/ResourceModel\/Gridapp\/code\/Webkul\/Grid\/Setupapp\/code\/Webkul\/Grid\/Controllers\/Adminhtmlapp\/code\/Webkul\/Grid\/view\/adminhtml\/layoutapp\/code\/Webkul\/Grid\/view\/adminhtml\/templates Now, as we have the directory structure ready, we will now create file as per module requirement <a href=\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":4,"featured_media":48469,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,302],"tags":[3096,588,2070],"class_list":["post-48474","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento","category-magento2","tag-crud","tag-grid","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2 - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Here we create Collection Grid , edit\/add grid row and installer in Magento2 Before starting the code section, let us create the directory structure that we will need for create admin grid edit\/add grid row and installer. app\/code\/Webkul\/Gridapp\/code\/Webkul\/Grid\/etcapp\/code\/Webkul\/Grid\/etc\/Adminhtmlapp\/code\/Webkul\/Grid\/Block\/Adminhtmlapp\/code\/Webkul\/Grid\/Block\/Adminhtml\/Gridapp\/code\/Webkul\/Grid\/Block\/Adminhtml\/Grid\/Editapp\/code\/Webkul\/Grid\/Modelapp\/code\/Webkul\/Grid\/Model\/ResourceModelapp\/code\/Webkul\/Grid\/Model\/ResourceModel\/Gridapp\/code\/Webkul\/Grid\/Setupapp\/code\/Webkul\/Grid\/Controllers\/Adminhtmlapp\/code\/Webkul\/Grid\/view\/adminhtml\/layoutapp\/code\/Webkul\/Grid\/view\/adminhtml\/templates Now, as we have the directory structure ready, we will now create file as per module requirement [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-09T09:39:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-21T06:41:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abhishek Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhishek Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/\"},\"author\":{\"name\":\"Abhishek Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0\"},\"headline\":\"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2\",\"datePublished\":\"2016-05-09T09:39:01+00:00\",\"dateModified\":\"2024-02-21T06:41:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/\"},\"wordCount\":666,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png\",\"keywords\":[\"CRUD\",\"grid\",\"Magento2\"],\"articleSection\":[\"magento\",\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/\",\"url\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/\",\"name\":\"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png\",\"datePublished\":\"2016-05-09T09:39:01+00:00\",\"dateModified\":\"2024-02-21T06:41:26+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png\",\"width\":825,\"height\":260,\"caption\":\"Upload files using magento2 mediastorage module\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0\",\"name\":\"Abhishek Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Abhishek Singh\"},\"description\":\"Adobe Commerce certified Magento developer with over 12 years of experience at Webkul. Passionate about scalable Magento 2-based webshops, AI, and multi-channel integrations, Abhishek consistently delivers innovative and efficient e-commerce solutions that propel businesses forward.\",\"sameAs\":[\"http:\/\/webkul.com\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/abhishek\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2 - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/","og_locale":"en_US","og_type":"article","og_title":"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2 - Webkul Blog","og_description":"Here we create Collection Grid , edit\/add grid row and installer in Magento2 Before starting the code section, let us create the directory structure that we will need for create admin grid edit\/add grid row and installer. app\/code\/Webkul\/Gridapp\/code\/Webkul\/Grid\/etcapp\/code\/Webkul\/Grid\/etc\/Adminhtmlapp\/code\/Webkul\/Grid\/Block\/Adminhtmlapp\/code\/Webkul\/Grid\/Block\/Adminhtml\/Gridapp\/code\/Webkul\/Grid\/Block\/Adminhtml\/Grid\/Editapp\/code\/Webkul\/Grid\/Modelapp\/code\/Webkul\/Grid\/Model\/ResourceModelapp\/code\/Webkul\/Grid\/Model\/ResourceModel\/Gridapp\/code\/Webkul\/Grid\/Setupapp\/code\/Webkul\/Grid\/Controllers\/Adminhtmlapp\/code\/Webkul\/Grid\/view\/adminhtml\/layoutapp\/code\/Webkul\/Grid\/view\/adminhtml\/templates Now, as we have the directory structure ready, we will now create file as per module requirement [...]","og_url":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-05-09T09:39:01+00:00","article_modified_time":"2024-02-21T06:41:26+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png","type":"image\/png"}],"author":"Abhishek Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Abhishek Singh","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/"},"author":{"name":"Abhishek Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0"},"headline":"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2","datePublished":"2016-05-09T09:39:01+00:00","dateModified":"2024-02-21T06:41:26+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/"},"wordCount":666,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png","keywords":["CRUD","grid","Magento2"],"articleSection":["magento","Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/","url":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/","name":"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png","datePublished":"2016-05-09T09:39:01+00:00","dateModified":"2024-02-21T06:41:26+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1.png","width":825,"height":260,"caption":"Upload files using magento2 mediastorage module"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/create-collection-grid-editadd-grid-row-installer-magento2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to create Collection Grid, Edit\/Add grid row, and Installer in Magento2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/573e459f54796eb4195511990de4bfd0","name":"Abhishek Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4ac7e0e671bf743359d7e3f140c262d1b16d71106f0a1aeaecca327a2805ae4?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Abhishek Singh"},"description":"Adobe Commerce certified Magento developer with over 12 years of experience at Webkul. Passionate about scalable Magento 2-based webshops, AI, and multi-channel integrations, Abhishek consistently delivers innovative and efficient e-commerce solutions that propel businesses forward.","sameAs":["http:\/\/webkul.com"],"url":"https:\/\/webkul.com\/blog\/author\/abhishek\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/48474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=48474"}],"version-history":[{"count":19,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/48474\/revisions"}],"predecessor-version":[{"id":423268,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/48474\/revisions\/423268"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/48469"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=48474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=48474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=48474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}