Skip to main content
added 11 characters in body
Source Link

So, everything you shouldneed - add to your data sourcedata_source collection class the following code:

So, you should add to your data source collection class the following code:

So, everything you need - add to your data_source collection class the following code:

added 9 characters in body
Source Link

The thing is, your SequenceNumber class changes data items only for ui grid rows, when _data_sourceyour_component_data_source is loaded, and if you want to get the same results with export, you should provide values for "No" column inside your_component_data_source collection class.

I suppose you have something like this in view/adminhtml/ui_component/your_component_nameyour_component.xml:

The thing is, your SequenceNumber class changes data items only for ui grid rows, when _data_source is loaded, and if you want to get the same results with export, you should provide values for "No" column inside your_component_data_source collection class.

I suppose you have something like this in view/adminhtml/ui_component/your_component_name.xml:

The thing is, your SequenceNumber class changes data items only for ui grid rows, when your_component_data_source is loaded, and if you want to get the same results with export, you should provide values for "No" column inside your_component_data_source collection class.

I suppose you have something like this in view/adminhtml/ui_component/your_component.xml:

Source Link

The thing is, your SequenceNumber class changes data items only for ui grid rows, when _data_source is loaded, and if you want to get the same results with export, you should provide values for "No" column inside your_component_data_source collection class.

I suppose you have something like this in view/adminhtml/ui_component/your_component_name.xml:

<dataSource name="your_component_data_source">
    <argument name="dataProvider" xsi:type="configurableObject">
        <argument name="class" xsi:type="string">Vendor\Module\Ui\Component\ModelNameGridDataProvider</argument>
        <argument name="name" xsi:type="string">your_component_data_source</argument>
        <argument name="primaryFieldName" xsi:type="string">id</argument>
        <argument name="requestFieldName" xsi:type="string">id</argument>
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="update_url" xsi:type="url" path="mui/index/render"/>
                <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
                <item name="storageConfig" xsi:type="array">
                    <item name="indexField" xsi:type="string">id</item>
                </item>
            </item>
        </argument>
    </argument>
</dataSource>

...and in your adminhtml/di.xml:

<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
    <arguments>
        <argument name="collections" xsi:type="array">
            <item name="your_component_data_source" xsi:type="string">Vendor\Module\Model\ResourceModel\ModelName\Grid\Collection</item>
        </argument>
    </arguments>
</type>
...
<!--The following can be a virtualType. In this case you should create it as real class to be able to modify collection-->
<type name="Vendor\Module\Model\ResourceModel\ModelName\Grid\Collection"><!---->
    <arguments>
        <argument name="mainTable" xsi:type="string">your_table_name</argument>
        <argument name="resourceModel" xsi:type="string">Vendor\Model\ResourceModel\ModelName</argument>
    </arguments>
</type>

So, you should add to your data source collection class the following code:

//app/code/Vendor/Module/Model/ResourceModel/ModelName/Grid/Collection.php

namespace Vendor\Module\Model\ResourceModel\ModelName\Grid;

class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
{
    protected function _afterLoad()
    {
        parent::_afterLoad();

        $counter = 0;
        $items = $this->getItems();
        foreach ($items as $item) {
            $item['no'] = ++$counter;
        }
        return $this;
    }
}

Then you should remove your Webkul\Marketplace\Ui\Component\Listing\Column\SequenceNumber class from UI component

and do not forget to clear cache (including m2root/var/di, since 2.2.0 m2root/generated/)

Still, you won't be able to sort rows by this column..