HOME PAGE | DOWNLOAD | TUTORIALS | XtraReports
Devexpress

Saturday, July 14, 2012

XtraGrid - Display Master-Detail Data

In this lesson, I’ll demonstrate how to use a Grid Control to present data in a Master-Detail format.
1.       First, I’m going to add a Detail Data Table to the Customers DataSet.
2.       To do this, I run the DataSet Configuration Wizard.
3.       Now, I’m going to select the Childs table for the Customers.
4.       Let it be the Orders Table.
5.       I choose the fields that I want to be retrieved,  . . . and click Finish.
6.       Notice that the detail buttons which I use to expand detailed views, are now displayed within the grid rows.
7.       This indicates that our Grid Control is ready to display Master-Detail data.
8.       By default, details will be represented by grid views.
9.       Now, I’ll show you how to change the view used to display detail data.
10.   For this purpose, first click the “Retrieve Details” button.
11.   The Grid Control creates a Master-Detail tree that corresponds to the structure of your data source.
12.   After the detail level has been created, we can associate a view with it.
13.   Let’s use a newly created Card View.
14.   After these steps are complete, I rebuild the solution.
15.   Finally, I need to supply the data to be displayed by the detail views.
16.   I drop the “Orders Table Adapter” onto the form.
17.   Then I can double-click the form, and write code within the form’s “Load” Event Handler to fill the dataset with the data provided by the “Orders Table Adapter”.
CODE:
ordersTableAdapter1.Fill(dsCustomers.Orders);
18.   And that’s all . . . I run the application to see the results.
19.   Expand the first master row.
20.   You can see that the detail data is now represented as cards.
21.   I can maximize the detail, so that it occupies the entire grid control’s window.
22.   Then, I can switch back to the main view.
The example shown in this lesson is the simplest Master-Detail structure you can display using the XtraGrid. You can have any number of nesting levels and any number of details at each level.
For additional information, please refer to the XtraGrid’s documentation.

Enhanced by Zemanta

No comments:

Post a Comment