We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Some problems obtaining a correct refresh on a detail grid when data are changed

Hi,

please consider the zip file I have here attached where you can find a modified project and a video that I have made to explain my question.
I have changed one of your examples regarding master-detail grid.
I have added a button that simply adds some extra detail records to the details data.
How can I obtain a correct refresh of the detail data on the record's details as soon as I click on my new button?
Thank you for your help.

Silvio



Attachment: MasterDetailsViewDemo_30b95a11.zip

3 Replies

SV Srinivasan Vasu Syncfusion Team June 15, 2017 07:01 AM UTC

Hi Silvio, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query and you have used List collection to bind with ItemsSource of SfDataGrid. When you adding the records in runtime, it will not be reflected in view. Because. List collection doesn’t support INotifyPropertyChanged. You can use ObservableCollection insteadof List, which will update the collection automatically when items are added or removed in runtime.  Whether the child records count is zero, you have to invoke the UpdateDataRow method when a new records added in runtime. 
 
Please refer the below code example. 
 
using Syncfusion.UI.Xaml.Grid.Helpers; 
using Syncfusion.UI.Xaml.Grid; 
 
  private void buttonAddDetail_Click(object sender, RoutedEventArgs e) 
        { 
            var context = this.DataContext as ViewModel; 
            var rec1 = context.OrdersDetails[4]; 
            var rec2 = context.OrdersDetails[3]; 
            rec2.OrderDetails.Add(new OrderDetails(1111, 7, 7, 7, 7, "7", DateTime.Now)); 
            if (rec1.OrderDetails.Count == 0) 
            {      
               // Whether the child records count is zero, you should invoke the UpdateDataRow method when a new record added in runtime.         
                 
                rec1.OrderDetails.Add(new OrderDetails(2222, 8, 8, 8, 8, "8", DateTime.Now)); 
                this.dataGrid.UpdateDataRow(this.dataGrid.ResolveToRowIndex(rec1)); 
            } 
        } 
 
 
We have modified the sample as per your requirement and you can download the same from the below location. 
 
 
Please refer the below Kb Link: 
 
 
Regards, 
Srinivasan 



SI Silvio June 15, 2017 07:57 AM UTC

Dear  Srinivasan Vasu 

thank you very very much!
Your help has been very usefull to me.
Have a nice day.

Silvio


SV Srinivasan Vasu Syncfusion Team June 16, 2017 04:06 AM UTC

Hi Silvio, 
  
Thanks for your update.  
  
Please let us know if you need further assistance. 
  
Regards,
Srinivasan 


Loader.
Live Chat Icon For mobile
Up arrow icon