Intro
If youre developing in Delphi and looking for a powerful, flexible, and highly customizable data grid solution, then TMS FNC Data Grid is the perfect choice. In this blog, we continue on our journey with the TMS FNC Data Grid. The TMS FNC Data Grid offers developers advanced tools for presenting and interacting with data. Master-Detail relationships is a feature to create intuitive and synchronized data representations, where a master grid shows parent records, and a detail grid reflects the corresponding child records based on the selected master entry.
Last Chance Launch Offer
*To celebrate this release, we're offering a 20% discount on all new licenses for both the TMS FNC UI Pack and TMS FNC Component Studio. Simply use the code DATAGRID at checkout. This offer applies to single developer, small team, and site licenses. This exclusive discount is valid until October 31, 2024.
Master-Detail
By linking the master and detail grids through the adapter, the detail grid can dynamically refresh and display the appropriate records from the child table. This is achieved by setting up datasets for both tables and using TDataSource components for database linking.
Setting up Master-Detail Tables
The master-detail relationship consists of:
- Master Table: Contains parent records (e.g., `Orders`).
- Detail Table: Contains child records linked to the master table (e.g., `OrderDetails` with a foreign key `OrderID`).
Configuring Database Components
- Create Datasets
- Create datasets for the master (`Orders`) and detail (`OrderDetails`) tables.
- Use `TDataSource` components to link the datasets (`dsMaster` and `dsDetail`).
- Place two `TTMSFNCDataGridDatabaseAdapter` components on the form.
- Set the `DataSource` of `MasterAdapter` to `dsMaster` and `DetailAdapter` to `dsDetail`.
Linking Master and Details Grids
- Master Grid Setup
- Drop a `TTMSFNCDataGrid` component on the form and set it to display fields from the master dataset (`Orders`).
- Bind this grid to `MasterAdapter`.
- Add another `TTMSFNCDataGrid` for the detail dataset (`OrderDetails`).
- Bind this grid to `DetailAdapter`.
- Set the `MasterSource` property of the detail dataset (`dsDetail`) to the master datasets `TDataSource`.
- Define the `MasterFields` to specify the linking key (e.g., `OrderID`).
- Set the DetailControl property of the `MasterAdapter` to `OrderDetails` Grid

Custom Detail
With TTMSFNCDataGrid, you have freedom of choice, and this also applies to setting up Master-Detail relationships. In this sample, we created a panel, added a TTMSFNCDataGrid instance which is bound to a detail table, and a chart, also setup via the same detail table.
Conclusion
Master/Detail relationships are crucial for efficiently presenting data from multiple sources. The "Master" view provides a high-level summary, while the "Detail" section shows specific information for a selected item. This approach enhances user experience by allowing easy navigation of large datasets, improving clarity, and enabling efficient data exploration. It's ideal for applications needing flexible, scalable, and intuitive data management.
In the next blog we'll explore how you can add column & row calculations, so stay tuned for more advanced tips and tutorials on leveraging this next-generation data grid for your Delphi projects! Happy coding!