1

I have a situation where I need to select all child rows in a lightning:treeGrid when parent row gets selected but lightning:treeGrid doesn't provide this behavior, is it a bug? How can I achieve it? enter image description here

The behavior can be seen in the picture I have selected the parent but child is still un-selected

Code :

<lightning:treeGrid aura:id="ATree" columns="{!v.gridColumnsArt}" data="{!v.gridDataArt}" keyField="id"  onrowselection = "{!c.getSelectedName}"/>
1
  • i dont see anywhere in the documentation that this is supposed to work OOTB, looks like you have to set the code yourself to have all children selected.
    – glls
    Sep 3, 2018 at 17:25

1 Answer 1

1

This is not possible with standard functionality of the component.

What you can do to achieve your requirements, is to use the onrowselection event:

<lightning:treeGrid aura:id="ATree" columns="{!v.gridColumnsArt}" data="{!v.gridDataArt}" keyField="id"  onrowselection = "{!c.getSelectedName}"/>

And then get all selected rows:

getSelectedName: function(cmp, event, helper) {
    var selectedRows = event.getParam('selectedRows');

    for (var i = 0; i < selectedRows.length; i++){
        alert("You selected: " + JSON.stringify(selectedRows[i]));
    }        
},

Inside this loop you should select all child nodes of the selected node

You must log in to answer this question.

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