This sample displays hierarchical data using nested drop grids.
In this sample,
The primary grid is the Customers table from the Northwind database.
If you click a row of this table, the Orders table will be displayed in a new grid, which shows the orders placed by the customers.
If you click any of the rows in the Orders table, it in turn drops another grid with the Order_Details table, which shows the order details of the selected row in the Orders table.
Features:
The sample has a derived GDBG class called GridHierDataBoundGrid, which is used for each of the three grids that are involved. In the constructor for this class, you must pass the tables that are used by this grid as well as the child table, if any.
To specify a relationship between a parent table and a child table, you must pass an event handler for the QueryFilterString event. Your event should specify the FilterString that defines the relationship between the parent table and the child table.
GridHierDataBoundGrid has a second event, which lets you format the grid just before it is dropped. You can use it to specify features such as background colors and other cell properties.
GridHierDataBoundGrid has an unbound column at the beginning to show the related tables as a drop-down. It uses a custom cell (DBDropDownGridCell) derived from GridDropDownGridCellModel and GridDropDownGridCellRenderer classes to display related tables. This cell model is added to GridHierDataBoundGrid in its constructor.
In the GridDropDownGridCellRenderer.OnInitialize override method, the QueryFilterString event is fired in order to obtain the filter string. A data view is created with this filter string and is assigned to the drop-down grid.
Formatting is applied to the drop-down grid by firing QueryFormatGrid event just before the drop-down container is shown in the GridDropDownGridCellRenderer.DropDownContainerShowingDropDown override.