5

I have a lightning web component, using lighting-datatable with row-numbers visible. This works well up to 99 records... then I get this:

[![enter image description here][1]][1]

My component code:

        <lightning-datatable
            key-field="id"
            data={responses}
            columns={columns}
            onsort={handleSort}
            sorted-by={sortedBy}
            sorted-direction={sortedDirection}
            onrowaction={handleRowAction}
            enable-infinite-loading
            onloadmore={handleLoadMore}>
        </lightning-datatable>

Is the row numbering limited, am I doing something wrong, or is this a bug? Any workarounds?

3
  • Please add the part that's an answer as an answer. You're allowed to answer your own questions here.
    – sfdcfox
    Commented Mar 23, 2019 at 18:00
  • Got it. I was thinking I had to wait before I could answer my own question... but I see the delay is just in accepting it. Commented Mar 23, 2019 at 18:10
  • yep. You're absolutely right. You've got my +1.
    – sfdcfox
    Commented Mar 23, 2019 at 18:19

1 Answer 1

5

Just figured it out myself. I didn't have show-row-number-column in the html. Now it works fine. But, that brings up a different question... what if I didn't want to show row numbers. The docs suggest that I would just leave show-row-number-column out of the markup and then they won't show. But I didn't have it in the markup before and they displayed.

enter image description here

Updated markup:

<lightning-datatable
    key-field="id"
    data={responses}
    columns={columns}
    onsort={handleSort}
    sorted-by={sortedBy}
    sorted-direction={sortedDirection}
    onrowaction={handleRowAction}
    show-row-number-column
    enable-infinite-loading
    onloadmore={handleLoadMore}>
</lightning-datatable>

BTW, there's a lot more info in the dev guide here that isn't detailed in the reference materials. In particular, how to handle draftValues, which is necessary to get the Cancel/Save buttons to disappear after an inline edit.

4
  • This is a bug in the component I just discovered too! I do not want to show the row numbers and apparently there is no way to hide them other that custom CSS which I am not sure will work because one of the nuances about LWC is the components exist in the ShadowDom and CSS won't cascade from parent to child.
    – binaryLady
    Commented Apr 30, 2019 at 15:21
  • I'm facing a similar on the aura version, showRowNumberColumn paramater doesn't work at all. Is there a workaround for this? @PatMcClellan__c
    – Atlas Can
    Commented Aug 29, 2019 at 6:37
  • Rows numbers are displayed if you have any columns in editable mode. It is mentioned in the docs. We can't hide them. Commented Jun 24, 2020 at 8:47
  • link in the answer is broken. Updated: developer.salesforce.com/docs/component-library/documentation/…
    – dev4life
    Commented Sep 6, 2020 at 2:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .