1

I have tried using the show-row-number-column = "false" attribute but it does not seem to work.

https://developer.salesforce.com/docs/component-library/bundle/lightning-datatable/specification

    <div class="slds-m-around_medium">
        <template if:true={voting}>
            <lightning-datatable
                key-field="Id"
                hide-checkbox-column = "true"
                data={voting}
                columns={columns}
                onsave={handleSave} 
                show-row-number-column = "false"  
                draft-values={draftValues}>
            </lightning-datatable>
        </template>
        <template if:true={voting}>
            <!-- handle Apex error -->
        </template>
    </div>

3 Answers 3

4

The attribute show-row-number-column set automatically to "true" if present we dont need to set it to "true" or "false" if you dont want row number Simply remove that attribute

  <lightning-datatable
                key-field="Id"
                hide-checkbox-column = "true"
                data={voting}
                columns={columns}
                onsave={handleSave} 

                draft-values={draftValues}>
            </lightning-datatable>

Also if the columns are editable,the show-row-number-column attribute is always true and the number column is displayed.

1
  • 4
    Confirming that this is true based on what I'm seeing: "if the columns are editable,the show-row-number-column attribute is always true". Seems kind of dumb, but there you go. Nov 7, 2020 at 6:44
0

Complementing @User6670 answer (which is perfectly valid), when you need to remove the RowNumber columns for editable datatable you can simply edit the css to hide the first column from the table.

Not the best option for sure, but worked fine to me. Use with caution.

.THIS tr td:first-child{
    display:none;
}
.THIS tr th:first-child{
    display:none;
}
-3

"show-row-number-column= false" property from Lightning datatable will work, Please post your code snippet for better analysis.

1
  • This doesn't work. Tested on the lightning-datatable. Mar 23 at 18:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.