How to add grid items in Magento 2

Posted at: September 21, 2018 4:04 PM

Create Allnews Interface

Rsgitech\News\Api\Data\AllnewsInterface.php

Create interface for fields

Implement Interface in Allnews Model

Rsgitech\News\Model\Allnews.php

Create AllnewsRepositoryInterface

Rsgitech\News\Api\AllnewsRepositoryInterface.php

Create AllnewsRepositoryInterface for save, delete, getById, deleteById

Create class AllnewsRepository

Rsgitech\News\Model\AllnewsRepository.php

Create class AllnewsRepository and implements interface AllnewsRepositoryInterface

Resource model Allnews

Rsgitech\News\Model\ResourceModel\Allnews.php

Here set created at and updated at date before save

Create file di.xml

Rsgitech\News\etc\di.xml

Create file acl.xml

Rsgitech\News\etc\acl.xml

Create ACL file for user authorization

Create block Allnews

Rsgitech\News\Block\Adminhtml\Allnews.php

Create Grid Block

Rsgitech\News\Block\Adminhtml\Allnews\Grid.php

Create GenericButton Block

Rsgitech\News\Block\Adminhtml\Allnews\Edit\GenericButton.php

Create BackButton Block

Rsgitech\News\Block\Adminhtml\Allnews\Edit\BackButton.php

Create DeleteButton Block

Rsgitech\News\Block\Adminhtml\Allnews\Edit\DeleteButton.php

Create ResetButton Block

Rsgitech\News\Block\Adminhtml\Allnews\Edit\ResetButton.php

Create SaveAndContinueButton Block

Rsgitech\News\Block\Adminhtml\Allnews\Edit\SaveAndContinueButton.php

Create SaveButton Block

Rsgitech\News\Block\Adminhtml\Allnews\Edit\SaveButton.php

Create Controller Action NewAction

Rsgitech\News\Controller\Adminhtml\Allnews\NewAction.php

Create new grid item

Create Controller Action Save

Rsgitech\News\Controller\Adminhtml\Allnews\Save.php

Create ui component form

Rsgitech\News\view\adminhtml\ui_component\news_allnews_form.xml

Create Layout

Rsgitech\News\view\adminhtml\layout\news_allnews_edit.xml

Load uiComponent news_allnews_form in news_allnews_edit.xml file

Then run below commands


Complete!!

Download complete source code: Download

You can watch video on How to add grid items in Magento 2


Grid Items Add Grid Item Magento 2 Admin Grid

Please leave comments

0 Comments

truecodex launched free android app. You can download and install truecodex app on your mobile and get notification of the latest post.

Video Tutorials on YouTube