Design-Time Features > Master-Detail Binding |
As we have already seen in the Server-Side Filtering example, C1DataSource supports master-detail binding. With very large datasets, server-side filtering is by far the best solution, but with smaller datasets, client-side filtering can be just as efficient. This scenario demonstrates client-side master-detail binding using a grid, instead of a combo box used in the previous Server-Side Filtering to select categories.
To implement master-detail binding, follow these steps:
Now add a second grid to the form below the one you’ve just configured. Its C1DataSource will again be the C1DataSource, but set its DataMember property to the Products node which you’ll find underneath Categories as shown in the following picture:
Selecting a category in the master grid causes the products linked to it to be displayed in the details grid (which as before is fully editable). Running this on a single machine, as you probably are, you won't notice any significant time lapse as you select new categories in the master grid and their respective products are displayed in the details grid. In the background, the C1DataSource is making use of an Entity Framework feature, implicit lazy loading, meaning that products are only being summoned for new categories as they are selected. For many scenarios, this is perfectly acceptable, but we began this section by specifically referring to master-detail relationships in small datasets. We might just as well fetch all of the products for all of the categories when the form loads and then display will be instantaneous whether on a single machine or across a network. To achieve this behavior, open the ViewSourceCollection editor and type Products in the Include property of the Categories view source.