Salesforce – How to get row index of lightning table rows

By | January 22, 2021

Dynamic lightning table components help you to display the records in the table format easily. In this blog, we will understand how to get a row index of lightning table rows.

  • If we want to do operation on the click on any column of table, we need a row index of respective rows.Firstly, we need to assign rowindex to rows as shown in the below code.
  • In below table, we have assigned an “InputNumberLabel” class for lightning table data so that we can assign style for respective row.
  • Also,we have included label attribute of <ui:inputNumber>  for storing a row index.
<table data-reactroot="" class="slds-table slds-table--bordered">
            <tr class="">
                <th scope="col">
                    <div class="slds-truncate">Product</div>
                <th scope="col">
                    <div class="slds-truncate">Quantity</div> 
            <aura:iteration indexVar="rowIndex" items="{!v.GetProductData}" var="product">
                <tr class="">
                    <td class="slds-text-align_right slds-text-body_small InputNumberLabel"  data-row-index="{!rowIndex}">
						<ui:inputNumber aura:id="idProduct" label="{!rowIndex}" value="{!product.Name}" change="{!c.DoAction}"/>	
                    <td class="slds-text-align_right slds-text-body_small InputNumberLabel" data-row-index="{!rowIndex}">
                        <ui:inputNumber aura:id="idQuantity" label="{!rowIndex}"  value="{!product.Quantity }" />
  • Get the row index of the respective row using following way:
DoAction: function(cmp,event,helper)
             var rowIndex=event.getSource().get("v.label");
  • Apply following css to the table data.
    • visibility:collapse hides an element entirely (so that it doesn’t occupy any space in the layout), but only when the element is a table element.
  • If we don’t apply visibility:collapse property, then rowindex will be display on the lightning Table UI.
.THIS .InputNumberLabel 
     visibility: collapse !important;

We hope you may find this blog resourceful and helpful. If you still have concerns and need more help, please contact us at

About Us
Greytrix – a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce Sage integration for Sage X3Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data MigrationIntegrated App developmentCustom App development and Technical Support to business partners and end users.
Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star rated app listed on Salesforce AppExchange.

The GUMU™ Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.

For more information on our Salesforce products and services, contact us at We will be glad to assist you.

Related Posts