0

I am trying to display data in my Lightning-Datatable where I have line items for each row. The problem is I cannot display those line items. I could use Tree Grid but I also want to display the column headers for the line items which tree grid does not do.

For example:

<lightning-datatable columns={columns} 
                     data={data} 
                     key-field="id"
                     hide-checkbox-column="true"
                     show-row-number-column="true"></lightning-datatable>

Where columns is my rows e.g:

const columns = [
                {
                label: 'A',
                fieldName: 'A',
                type: 'text'
                }, 
                {
                    label: 'B',
                    fieldName: 'B', 
                    type: 'text'
                }
            ];

But then I want to display a line item for each one of the rows which could look like:

const lineItems = [
                {
                label: 'A1',
                fieldName: 'A1',
                type: 'text'
                }, 
                {
                    label: 'B1',
                    fieldName: 'B1', 
                    type: 'text'
                }
            ];

Where the column headers are showing for both. Is this possible? I cannot find any standard components on this.

1

1 Answer 1

3

You'll want to use the lightning:treeGrid. The children for each item are in a special attribute named _children. See the documentation (above) for all the details.

You must log in to answer this question.

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