SfDataGrid allows you to enable NestedGrid even when you do not have any relations in your data source, by handling “DetailsViewExpanding” event. You can use the DetailsViewItemsSource property of GridDetailsViewExpandingEventArgs to set ItemsSource for NestedChild.
The GridDetailsViewExpandingEventArgs contains the following properties:
For example, consider two ItemsSource “OrderInfo” and “OrderDetails” where the ItemsSource OrderDetails is the NestedChild of OrderInfo. The DetailsViewExpanding event occurs whenever the Nested Expander is pressed .The event can be invoked by creating an empty Relation as illustrated in the following code example. You can give any name to the RelationColumn as you are creating relations to show the Nested Expander, so that when clicking the expander you can load the ItemSource by handling DetailsViewExpanding event. The HideEmptyGridViewDefinition property of the SfDataGrid is to be set false to display the empty grid. XAML
The following snapshot illustrates the output of the above code in SfDataGrid, in which an empty NestedGrid is created.
Now, you can create OrderDetails as NestedChild of OrderInfo by handling the event “DetailsViewExpanding” and setting DetailsViewItemSource in that event from the “OrderDetails” table, as shown in the following code example. C#
Here, the two ItemsSource are related using the property “OrderID”. The following snapshot illustrates the effect of above code in SfDataGrid.
Sample Links: |
This page will automatically be redirected to the sign-in page in 10 seconds.