We are loading the ItemsSource for a DataGrid DetailsView like described here:
https://help.syncfusion.com/wpf/datagrid/master-details-view#loading-detailsviewitemssource-asynchronously
e.DetailsViewItemsSource.Clear();Does clear the Dictionary, because we have the RelatedColumn name as Key we are only able to add a single set of data for one DetailsView:
e.DetailsViewItemsSource.Add("ProductDetails", itemsSource);That actually results in the following behavior of the DataGrid:
We actually expect the DataGrid to hold the recently added data items for each of the DetailViews, so that any further expanding/collapsing does keep the data of each DetailView intact.
How to achieve this? When we try to use the individual key, that relates to the parent record, in the dictionary we do not get the data in the DetailsView.
Thanks for any suggestions on this.
|
this.dataGrid.DetailsViewExpanding += OnDetailsViewExpanding;
void OnDetailsViewExpanding(object sender, Syncfusion.UI.Xaml.Grid.GridDetailsViewExpandingEventArgs e)
{
var orderID = (e.Record as OrderInfo).OrderID;
var itemsSource = (this.DataContext as ViewModel).order.getorder(orderID);
//assign the new ItemsSource to Child collection property
(e.Record as OrderInfo).OrderDetails = itemsSource;
} |
Hello Vihayarasan,
thanks for the example. However, in our case, that requires us to either modify the underlying data model (which in some use cases is not possible), or to create an intermediate data model that has a details property and rebase the data over (which is costly in view of application resources).
So for every single datagrid in an application custom code needs to be created for that, that is also costly because of development time.
We are using the datagrid together with an ObjectDataProvider and use a Behavior with properties, telling the ObjectDataProvider how to get the ItemsSource for the details (in a WPF application). That way we have always the same code, the data source provides the ObjectDataProviders, and simply configure the datagrid in the XAML view.
When expanding the detail our goal is to retrieve the related data through the ObjectDataProvider asynchronously, to have the UI thread clear of data related tasks.
The use of a dictionary in the datagrid already proposes that it could be used for storing the details data, however we understand that the thought is not completely thought through in the SF datagrid approach.
We find that it would a beneficial addition to the SF DataGrid to have above possibility available, to be able to fully dynamically add details data to the record in the grid without the need of any work-around on underlying data models.
Thanks for your answer.
|
this.dataGrid.DetailsViewLoading += OnDetailsViewLoading;
private void OnDetailsViewLoading(object sender, Syncfusion.UI.Xaml.Grid.DetailsViewLoadingAndUnloadingEventArgs e)
{
//assign the new ItemsSource to DetailsViewDataGrid ItemsSource property
//While assign the ItemsSource its only affect the particular DetailsViewDataGrid
e.DetailsViewDataGrid.ItemsSource = itemsSource;
} |
Hello Vijayarasan,
thanks for the explanation, that makes more sense then. Maybe update your documentation, because we where lead to understand the reported route and disregarded to use the ItemsSource property on the Details Grid.
Thanks for your replies.