Create admin grid listing in Magento 2

Posted at: September 21, 2018 3:12 PM

Create Model File Allnews.php

Rsgitech\News\Model\Allnews.php

Create Resource Model

Rsgitech\News\Model\ResourceModel\Allnews.php

Define table in resource model

Create Collection

Rsgitech\News\Model\ResourceModel\Allnews\Collection.php

Define model and resource model

Create Grid Collection

Rsgitech\News\Model\ResourceModel\Allnews\Grid\Collection.php

Create file status.php

Rsgitech\News\Model\Allnews\Source\Status.php

It is dropdown of status like as enabled and disabled

Create Action Column of Grid Items

Rsgitech\News\Ui\Component\Listing\Column\AllnewsActions.php

You can create action of grid items like edit, delete, view etc.

Create file di.xml

Rsgitech\News\etc\di.xml

Controller Action Index.php

Rsgitech\News\Controller\Adminhtml\AllNews\Index.php

Change controller file like this

Create view file of ui component

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

Layout

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

Load uiComponent news_allnews_listing in news_allnews_index.xml file

Then run below commands


Complete!!

Download source code: Download

This lesson also available on YouTube
Grid Listing Admin Grid Grid Filters

Please leave comments

4 Comments