Can I suggest a component that allows the view of a master table
along with its detail table from the same grid.
This would allow a nested view of data.
See below the type of view required from the master detail records from a fast food order
where the extras ( No Ketchup , Extra Onions etc. are stored in a detail table),
but all details visible in a single grid in an easy to see and understand format.
(There can be a setting to autodisplay the detail records or hide the detail as needed until clicked.)
Hamburger
-- No Ketchup
-- Extra Onions
Apple Pie
Coca Cola
-- No Ice
This would be a powerful way of displaying related data together in one view.
Hi Kamran,
as you show in your example it's not more easy work with one stringgrid and reading the tow tables.
The record stored in mastar table rapresent the first node level (first value, i.e. Hamburger) after read the detail and show all the items as node items.
I do this way in my program and it's very fast when i have to load hundred (or few thousand) records stored in 3 tables (customers, buied items, gift).
The advantage is you can handle all the tables you need and build the node at your own need and, using a checkbox you can handle the choice within the node.
In the other side you have to do all the job "manually" without dataware component.
This demo is "build" with array that simulate the tables.
Records:
The mail one
type MainCourse = record // Simulate master table
Name : String[50];
idx : Integer;
end;
keep the name of the course (fantasy) and the it own idx.
The second one
type Ingrediants = record // Simulate detail table
Idx : Integer;
Food : String[50];
Extra : Boolean;
Default : Boolean;
end;
Keep the index (idx) where the food is used for the course.
Default meaning that the course start with it ... but you can remove; If you remove it there's no logic you can use extra.
Extra meaning ... give some more ....
There's no difference between the array and the table regarding the "program logic".
The arraies has one filed in common, Idx, as happend in the tables to link master and detail.
So while here i check the idx value for each record into the array, in your table you must filter the detail one with the field in common.
The grid is a standard TMS stringgrid with FixedRowAlways set to true in order to keep the first row (column row), even goEdit (options) is set to true to allow work with check box.
Some event are setted in order to work with checkbox.
Be sure to declare one common field because the node works on one column.
So BEFORE apply the node, you MUST fill ALL THE GRID ad set the node at the end.
As i told you before, for few thousand records in 3 tables the speed is fast enougth (less than a second).
I just downloaded.. the example. do you have the full source files including the dfm etc..
I think the zip only contains the project.dpr file and unit1.pas only.