Some problems obtaining a correct refresh on a detail grid when data are changed
Hi,
Attachment: MasterDetailsViewDemo_30b95a11.zip
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
SIGN IN To post a reply.
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.
Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/MasterDetailsViewDemo1908617693.zip
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
Srinivasan
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
SI Silvio
- Jun 14, 2017 04:00 PM UTC
- Jun 16, 2017 04:06 AM UTC