Master-Detail Tutorial. Step 2: Level Structure
- 2 minutes to read
To represent data from a single dataset within EQGrid, you need to create a level-View pair. Grid levels are destined to create a hierarchical structure of data. Each level is bound to a View and this displays data in a form. Refer to the Data Representation topic for more information.
This section shows the creation of level-View pairs to represent four datasets. EQGrid provides the Structure Navigator to facilitate the creation of levels and Views.
- Place a TcxGrid control onto the form. The grid by default contains one level-View pair (cxGrid1Level1-cxGrid1DBTableView1):
This View will display data from the master FILMS table. Click the left mouse button on the cxGrid1Level1 box in the Structure Navigator so as to display its properties in the Object Inspector.
Rename cxGrid1Level1 to lvFilms using the Object Inspector. Similarly, rename cxGrid1DBTableView1 to tvFilms.
- Click the right mouse button on the lvFilms box to display the popup menu. Then select the Add Level option.
This adds a child grid level and this will represent data from the FILMSPERSONSSTAFF table. Set the name of the new level to lvStaff as described above.
Right-click the lvStaff box and select the Create View->DB Table option.
Now the lvStaff level is associated with a data-aware View and this will display data from the FILMSPERSONSSTAFF table. Set the name of the new View to tvStaff.
- Click the right mouse button on the lvFilms box again and add another level to display data from the FILMSSCREENS table. Rename the grid level to lvFilmScreens. Then associate a Card View with the level by selecting the Create View->DB Card View option from the level’s popup menu.
The newly created View should be renamed to cvFilmScreens.
- We want the PERSONS table to be displayed at the same hierarchy level as the FILMS table, i.e. at the ‘root’ hierarchy level. To add a level-View pair at the root, right-click the cxGrid1 box and select the Add Level menu item.
Next, associate a new data-aware View with it as shown in the previous section. Set the names for the new level and View to lvPersons and tvPersons respectively. Note that we are using a convention where Table Views and Card Views have prefixes ‘tv’ and ‘cv’ respectively (this is not mandatory though).
Finally, your grid will look like: