3

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?

  • Please add the part that's an answer as an answer. You're allowed to answer your own questions here. – sfdcfox Mar 23 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. – PatMcClellan__c Mar 23 at 18:10
  • yep. You're absolutely right. You've got my +1. – sfdcfox Mar 23 at 18:19
4

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.

  • 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 Apr 30 at 15:21

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.