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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to enable NestedGrid when I don't have relations in my datasource

Platform: Silverlight |
Control: SfDataGrid |
.NET Framework: 4.5

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:

  • CancelIf this property is set to true, the event is cancelled and the Details View is not be expanded.
  • Record – Get the row data.
  • DetailsViewItemsSource – A dictionary of strings and IEnumerable objects that holds the Relational Column as its key and the item source as its value.

 

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:

WPF

WinRT

SilverLight

UWP

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile