How to add autoincrement serial number in ui component admin grid?

by jassi   Last Updated January 13, 2018 05:09 AM

I have created grid using ui component. I want to add column serial number.

I added primary key i.e item_id of table. But if record gets deleted then serial number does not work.

=> Ex : I deleted record 2 then serial number column will display no. 1,3,4,5...

Is there any element which define autoincrement in xml.

     <column name="item_id">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="sorting" xsi:type="string">asc</item>
                <item name="label" xsi:type="string" translate="true">Sr No</item>
            </item>
        </argument>
    </column>


Answers 1


Replace this code :

<column name="item_id">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">textRange</item>
                    <item name="sorting" xsi:type="string">asc</item>
                    <item name="label" xsi:type="string" translate="true">Id</item>
                    <item name="sortOrder" xsi:type="number">20</item>
                </item>
            </argument>
        </column

This code will be helpful to you.

Rohan Hapani
Rohan Hapani
January 13, 2018 04:20 AM

Related Questions




Magento 2 - How to add the DateTime UI Component

Updated August 20, 2016 08:03 AM

What is reverseMetadataMerge in UI Components?

Updated January 11, 2017 08:03 AM