TreeGrid not refreshing after updating datasource when using hierarchy data binding

Hello

I have an issue regarding datasource updates when I try the hierarchy data binding demonstrated on this page:

I added a button that adds a new item and changes the name on some items. 

I can’t get the TreeGrid to update and display the altered tree without refreshing the whole page. 

I saw that there has been an earlier issue concerning the TreeGrid datasource before and that it had been resolved. But did that also include the hierarchy data binding?


1 Reply

PK Padmavathy Kamalanathan Syncfusion Team May 26, 2020 01:47 PM UTC

Hi Nicklas,

Thanks for contacting Syncfusion Forums.

QUERY:  Tree Grid not refreshing after updating data source when using hierarchy data

We do not have support for two way binding for hierarchy data. We suggest you to use the "UpdateRow" method with index and data as parameters for changing the column values and "AddRecord" method with data and index(index where new data should be inserted) as parameters for adding new record to the Tree Grid in the button click event. This way you can update and refresh data source of Tree Grid.

Please refer the below help documentations,


Please check the below code snippet,
in button click event  

 
public void OnToggleClick(MouseEventArgs args) 
    { 
        ----------- 
        var data = TreeData.Where(s => s.TaskId == 1).FirstOrDefault(); 
        var value = data2; 
        data.TaskName = "Changed"; 
        --- 
        this.treeGrid.UpdateRow(0, data); // calling UpdateRow method , data is row's changed data 
        this.treeGrid.AddRecord(data2, 0); // calling Addrecord method ,value is new record to be added 
  
    } 



Kindly get back to us for further assistance.

Regards,
Padmavathy Kamalanathan



Loader.
Up arrow icon