RowSelected and RowDeselected in TreeGrid when using AutoCheckHierarchy and ShowCheckbox

1. I saw that RowSelected and Deselected are triggered when the Checkbox is selected, does not matter if is a parent or child but when you select a row for the second time on the same page, the RowDeselected is triggered before the RowSelected event. And when you deselect a row the RowDeselect is triggered first but the args data is the last selected one-row data and no the deselected one, after the RowSelected es executed with the deselected row data as args.data.
I tried with CheckboxChange but this only returns the Index or Indexes but not the data and the GetRowByIndex is deprecated.
I add a sample code to reproduce the bug.
2. Is there a method to get all the selectedCheckRows? the GetCheckedRecords(), gets the checked records on the current page of the grid

Attachment: repos_3b99511b.rar

3 Replies 1 reply marked as answer

PS Pon Selva Jeganathan Syncfusion Team February 24, 2021 01:42 PM UTC

Hi Adriana,    
    
Thanks for contacting syncfusion forum. 
 

Query1 : RowSelected and RowDeselected in TreeGrid when using AutoCheckHierarchy and ShowCheckbox


Based on your query, you are using the checkbox column feature. The rowselection and checkbox column(showcheckbox property and autohierarchy property) are different.  Checkbox column is only used for selecting the records hierarchically. If a checkbox is checked, it does not indicate that the respective row is selected. 
 
So, the RowSelected and RowDeselected events are invoked based on the status of the highlighted rows (i.e. selected rows) not based on the selected checkboxes. 
 
Please refer to the below documentations for more details: 
 
 
 
If you want to select the row based on checkbox and row selection event, we suggest you to use the checkbox selection feature. 
 
Please refer to the below demo and documentation: 
 
Query 2: Is there a method to get all the selectedCheckRows? 
 
We are able to replicate the problem at our end in your specified scenario(“The GetCheckedRecords method doesn't work properly with enable paging.) with that latest version. Further analyzing we have confirmed this issue “The GetCheckedRecords method doesn't work properly with enable paging.” as bug. Thank you for the taking the time to report the issue and helping us improve our product. At Syncfusion we are committed to fixing all the validated defect (subject to technological feasibility and Product Development Life Cycle) and including its fix in our subsequent release. The fix for the issue will be included in third week of March, 2021 patch release.   
   
You can track the current status of your request, review the resolution timeline and contact us for any further inquiries through this link.       
   
Note: To view the above feedback, kindly login into your account.       
    
Please get back to us if you need any further assistance.   
 
Regards,   
Pon selva   






AS Adriana Selena Tito Ilasaca February 24, 2021 08:52 PM UTC

Thanks for the answer your suggestion to use the checkbox selection feature, when I select a parent does not select the children that is why I am using the showcheckbox property and autohierarchy property, and also the position of a checkbox, when is a parent and when is a child, I saw that ChechboxChange is an event triggered when I select the checkbox, I can know if was selected or deselected, because args has RowIndex but I cant get the data by args. Any other Suggestion? 


PS Pon Selva Jeganathan Syncfusion Team February 25, 2021 01:39 PM UTC

Hi Adriana,   
 
Thanks for the update. 
 

Query:   I saw that ChechboxChange is an event triggered when I select the checkbox, I can know if was selected or deselected, because args has RowIndex but I cant get the data by args. Any other Suggestion? 

Based on your query, We suggest that you use  the GetCurrentViewRecords method. You can get the selected data using the GetCurrentViewRecords method with the selected row indexes.

Please refer to the below code snippet,

 
<SfTreeGrid @ref="treeGrid" …> 
             <TreeGridEvents CheckboxChange="chekboxchange" TValue="WrapData"></TreeGridEvents> 
….. 
                </SfTreeGrid> 
…. 
 
    protected void chekboxchange(CheckBoxChangeEventArgs<WrapData> args) 
        { 
            var index =args.SelectedRowIndex; 
            var data = this.treeGrid.GetCurrentViewRecords()[Convert.ToInt32(index)]; 
            Console.WriteLine(data); 
 
 
        } 

Please refer to the below screenshot: 
 
 
Please refer to the below sample, 
 
Please refer to the below API documentation: 
 
Kindly get back to us for further assistance. 
 
Regards,   
Pon selva   


Marked as answer
Loader.
Up arrow icon