How to manage Grid UI Component Using Custom Dataprovider

In Magento 2, Ui component is used to build a grid on admin 1 and instead block and template in magento 1.

But when using it with a custom dataprovider, you may have a problem like this:

The reason for the magento 2 core’s export control is that they use the setCurPage () function instead of the setCurPage () function.

So you should add this function to your collection file. The example below illustrates this issue more clearly.

Classify Data provider in the UI component file:

File directory: app/code/Webnexs/OrderSuccess/view/ui_component/os_needverify_listing.xml

<listing xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">

    <argument name="data" xsi:type="array">



    <dataSource name="os_needverify_listing_data_source">

        <argument name="dataProvider" xsi:type="configurableObject">

            <argument name="class" xsi:type="string">Webnexs\OrderSuccess\Ui\DataProvider\NeedVerifyDataProvider</argument>






Init collection in Dataprovider file:

File directory: app/code/Webnexs/OrderSuccess/Ui/DataProvider/NeedVerifyDataprovider.php

namespace Webnexs\OrderSuccess\Ui\DataProvider;

class OrderDataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider {

    protected $needVerifyCollectionFatory;

    public function __construct(




        \Webnexs\OrderSuccess\Model\ResourceModel\Order\NeedVerify\CollectionFactory $needVerifyCollectionFatory,

        array $meta = [],

        array $data = []

    ) {

        parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);

        $this->needVerifyCollectionFatory = $needVerifyCollectionFatory;    



    public function initCollection()


        $collection = $this->needVerifyCollectionFactory()->create();

        $this->collection = $collection;


    public function getSearchCriteria(){

        return $this->getCollection();



Form resource collection

File directory:


namespace Webnexs\OrderSuccess\Model\ResourceModel\Order;

class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult


    public function __construct(

        EntityFactory $entityFactory,

        Logger $logger,

        FetchStrategy $fetchStrategy,

        EventManager $eventManager,

        $mainTable = 'sales_order',

        $resourceModel = '\Webnexs\OrderSuccess\Model\ResourceModel\NeedVerify'

    ) {

        parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel);


    public function getCurrentPage(){

        return $this->getCurPage();



    public function setCurrentPage($currentPage){

        return $this->setCurPage($currentPage);



Note: We need to get the GetCurrentPage () and setCurrentPage () functionality to getCurPage () and setCurPage () functionality. The problem will be fixed.

The above mentioned is the simplest process for you to manage Grid UI Component Using Custom Dataprovider . With this information, you can handle the Grid UI Component Using Custom Dataprovider effortlessly.

Last Update: April 7, 2018  

March 5, 2018   387   Nandini Ramachandran    Operations    
Total 1 Votes:

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

Leave a Reply

Your email address will not be published. Required fields are marked *