Skip to main content

Master-Detail Tutorial. Overview

  • 2 minutes to read

This tutorial covers the steps required to display data from several tables within a single TcxGrid control. EQGrid lets you display master-detail relationships between tables. You are also able to display data from independent tables and this is also demonstrated in this tutorial.

Consider the FILMS, FILMSPERSONSSTAFF, FILMSSCREENS and PERSONS tables that are shipped with the EQGrid demos and contain various data on the films in our collection.

The FILMS table contains information on films in the catalog and such fields as CAPTION, YEAR, PHOTO, TAGLINE, ID and others. ID is the key field name uniquely identifying each record in the table.

The FILMSPERSONSSTAFF table describes people involved in film production. It also has an ID field uniquely identifying records in this table. Other fields are PERSONID, PERSONLINEID, DESCRIPTION and FILMID. FILMID denotes a value of the ID field from the FILMS table. It associates each record in the FILMSPERSONSSTAFF table with a specific film from the FILMS table. Thus a master-detail relationship can be established between these tables in which FILMS is a master table and FILMSPERSONSSTAFF is a detail table.

A similar master-detail relationship can be set up between the FILMS and FILMSSCREENS tables. The latter provides images associated with films. It contains the following fields: ID (unique key field), FILMID (addresses a film from the FILMS table) and SCREEN (a BLOB field containing an image).

The PERSONS table represents information on the people in our video catalog. It does not contain any dependent fields and we want this table to be displayed in the same grid control.

The following screenshot shows the resultant grid control after you complete this tutorial. The independent FILMS and PERSONS tables are displayed at the root hierarchy level. You can access them via the Films and Persons tabs respectively:

Two detail tables (FILMSPERSONSSTAFF and FILMSSCREENS) are associated with the FILMS table. You can switch between them via the Staff and Film Screens tabs.

See Also