1

To display the first name of a member in the first column of my <lightning-tree-grid>, I am using type url to make it clickable, navigating to its record.

{ label: 'First Name', fieldName: 'MemberRecord', type: 'url', typeAttributes: { label: { fieldName: 'MemberFirstName' } } },

This works as expected as depicted below.

enter image description here

However, when displaying groups in the first column, they are shown as URLs as well. Below I am grouping by age group, which would show Adult (10) (contains 10 items) but instead has https:// added and is clickable like a link as well.

enter image description here

I would like to see First name (the original column) displayed as link, like it is now, but when grouping by another column I would like the group to be displayed as plain text.

How do I achieve this?

Update (added suggested info & code)

  1. In the <lightning-tree-grid> HTML component I am setting the columns property with relevant column data directly
  2. When the page loads, an Apex call is being done, loading the grid data
  3. Then some functions are called to (re-)group the data and set the gridData variable, which is assigned to the <lightning-tree-grid> HTML component and was empty initially when columns were already assigned to the component
  4. This process is triggered again when columns are re-grouped through the user interface (UI) and the gridData variable is re-assigned

The key here is that on first load of the page the issue already occurs, even when the data is already grouped initially.

Even if I assign dummy data to the gridData variable directly and skip the Apex call and (re-)grouping of data, the issue already occurs

Minimum Example (input data - tested)

columns = [
    { 
        label: 'First Name',
        fieldName: 'MemberRecord',
        type: 'url',
        typeAttributes: { 
            label: { fieldName: 'MemberFirstName' }
        }
    },
    { label: 'Last Name', fieldName: 'MemberLastName', type: 'text' }
];

gridData = [
    {
        MemberRecord: 'Johnson (1)',
        _uniqueRowid: 'group_1',
        _children: [
            {
                MemberRecord: 'https://example.com/member/1',
                MemberFirstName: 'Thomas',
                MemberLastName: 'Johnson',
                _uniqueRowid: 'student_1'
            }
        ]
    },
    {
        MemberRecord: 'Williams (2)',
        _uniqueRowid: 'group_2',
        _children: [
            {
                MemberRecord: 'https://example.com/member/2',
                MemberFirstName: 'John',
                MemberLastName: 'Williams',
                _uniqueRowid: 'student_2'
            },
            {
                MemberRecord: 'https://example.com/member/3',
                MemberFirstName: 'James',
                MemberLastName: 'Williams',
                _uniqueRowid: 'student_3'
            }
        ]
    }
];

HTML:

<lightning-tree-grid
    key-field="_uniqueRowid"
    columns={columns}
    data={gridData}
>
</lightning-tree-grid>
6
  • Do you change the grouping at runtime (i.e. handling an action)? If so, could you please edit the question adding the relevant part? Commented Mar 5 at 21:27
  • @RubenDG Thank you for your comment! I have Updated my question with elaborate additional details Commented Mar 6 at 11:34
  • i dont see any MemberFirstName or MemberLastName in parent record data, how will it work without those ? Commented Mar 7 at 14:26
  • @User6670 The parent (group) records show only the first field (MemberRecord), which will be filled with the Group name + member count. Commented Mar 7 at 14:41
  • @Z0q but you use that in label as typeAttributes: { label: { fieldName: 'MemberFirstName' } } when you dont have that in parent Commented Mar 7 at 14:46

1 Answer 1

0

Not really a solution but it did solve the problem for me:

I made the second column (Last Name) a clickable link and left the first column (First Name) regular text type so Group names show like normal.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.