0

I am using a lightning-datatable. I have a description field for one of my columns that I would like to better display the text. I would like to either be able to have 3 lines for this field if the data needs it. I tried to use wrapText: true but that just bleeds the text into the next field. I tried looking for a full list of column cellAttributes without success. How can I display the Description field so it shows multiple lines if needed?

    const cols = [
    { label: 'Status', fieldName: 'Status__c', sortable: "true", initialWidth: 90},
    { label: 'Number', fieldName: 'Group_Number__c', type: 'text', sortable: "true", initialWidth: 125 },
    { label: 'Eff Date', fieldName: 'Effective_Date__c', type: 'date-local', sortable: "true", initialWidth: 10},
    { label: 'Description', fieldName: 'Description__c', type: 'longtext', sortable: "true",  initialWidth: 520, editable: true, wrapText: false},
    {label: 'Actions', type: 'action', fixedWidth: 70, fixedHeight: 90,
        typeAttributes: {
            rowActions: actions,
           // menuAlignment: 'right'
        }
    }
];

1 Answer 1

0

You need to set number of visible lines as data-table attribute wrap-text-max-lines. Like this.

<lightning-datatable
                key-field="id"
                data={data}
                columns={columns}
                wrap-text-max-lines=3>
</lightning-datatable>
1
  • Thank you! That worked along with ensuring the column had wraptTest: True.
    – Frank
    Aug 19, 2021 at 13:46

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.