Can we use accordion feature in Lightning-Datatable LWC ? or Any other way to achieve same functionality in Lightning-Datatable LWC?
We have already built Lightining-datatable and using all its features such as column sorting, column header actions, row actions. Now the requirement is we need show child record using accordion feature.
As far as i know, we do have tree feature, or we can use accordion feature, but we can not use them with Lightning-datatable. We can use custom HTML table with slds tags as alternative to achieve, but in our case we already developed Lightning-datatable and using its features such column header action, row action, sorting etc.
Can someone suggest any alternative to achieve accordion in Lightning-datatable LWC.
Best Answer
On the assumption I've understood your question correctly, we have done this as follows:
For us, our datatable gets rendered like the following example, where the "Match" column is the one containing an accordion:
The row height adjusts depending on whether the accordion is open or closed, as illustrated.
You will find documentation about handling columns with "custom data types" under "Creating Custom Data Types".