function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nidhi Sharma 144Nidhi Sharma 144 

lightning:treegrid find Id/data of deselected row

Hi,

I am working with a lightning:treegrid component.
The onrowselection attribute of lightning:treegrid invokes a method on js controller whenever a row is selected/deselected.
I am able to fetch the currently selected rows using the getSelectedRows() method.
But if I deselect a row, I am not able to find its Id or row data (which is deselected) in the js controller.

Aura:
<lightning:treeGrid columns="{!v.gridColumns}"
                                    data="{!v.gridData}"
                                    keyField="idRef"
                                    aura:id="productTree"
                                    expandedRows="{! v.gridExpandedRows }"
                                    onrowselection="{! c.getSelectedRows}"
                                    ontoggle = "{!c.handleToggle}"
                                    selectedRows = "{!v.selectedIds}"
                                    isLoading="{! v.isLoading }"
                                    />

JS:
getSelectedRows: function(cmp, event, helper) {
       //get selected rows
        var curRows = event.getParam('selectedRows');

       //how to get the row that is deselected
    }

Can anyone please help?

Regards,
Nidhi Sharma
gbd mgbd m
You need to use following syntex to get the selected rows into treegrid on your event handlar function into lightning component:

var selectedRows = cmp.find('treegrid_async').getSelectedRows();

Regards,
Kheta Ram Sansi
Sohan ShirodkarSohan Shirodkar
Hi Nidhi,

Were you able to find a solution for this? I am also having the same question. lightning:treegrid has lots of limitations regarding select and deselect which makes it practically difficult to implement and use.