Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to create a master-detail grid

$
0
0

Update:
Starting with version 12.1, you can create a master-detail grid without any custom templates using the DataControlDetailDescriptor class. See the example project below for more information.


With later versions of our controls you can use the previous workaround:
The following example demonstrates how to create a master-detail grid.

To accomplish this, it is necessary to create a custom template for master-grid rows and place a nested grid control for details displayed within this template. The detail grid DataSource property should be bound to the appropriate column in the master grid. So, there will be a dedicated nested grid in every row of the master grid.

Since the count of detail grids is equal to the master grid row count, it is necessary to handle visibility and data binding of the detail grid to avoid a reduction in performance. Every detail grid must be hidden until it's master row is collapsed to show the detail information. That is why the detail grid in this example is wrapped with the GridDetailContainer class.

This class is designed to manage the Visibility and the DataSource properties of the nested grid. It has the IsVisible dependency property bound to the master row's IsExpanded attached property. When the master row expands the GridDetailContainer it sets the grid Visibility property to Visible and assigns it's DataSource. This adjustment is performed in the IsVisibleChanged callback.

So, the rendering and data source binding is required for visible detail grids only to help keep performance at a high level.

Note that this approach is a temporary solution, which is intended to be used until master-detail mode is truly supported in the DXGrid suite. If you want to be notified when this feature is implemented, track the corresponding suggestion: Data Binding - Master-Detail support.

Also please note, that by default, there is no Expander control in Silverlight SDK. In this example, the Expander from Silverlight Toolkit package is used. You can easily download this tool kit from the Silverlight Toolkit site.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>