DBGRID: Master-Detail View from the same instance of dbgrid.

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.

Thank you.

We will investigate.
With TAdvStringGrid, a grid in a grid can be done with:
https://www.tmssoftware.com/site/asg57.asp
I guess you mean a similar structure with the TDBAdvGrid?

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.

Excuse me if i do not uderstan the problem ...

Regards

Daniele

Hello

Thanks for the response.

Do you have a simple example code to illustrate this ?

Many thanks

Kamran

Hi,
i'll try to isolate the code from my program and i'll post it here ...

Daniele

Hi Kamran,
here you can find a little project

GridWithNode.zip (7.5 KB)

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).

Hope this is what you are need .....

Regards
Daniele

PS: Sorry for any type mistake ....

Hello Daniele

Good Morning.

Thank you so much for the project example and taking time to put it together.
Thats a great help for me.
I will try this for sure.

Regards

Kamran

Hi Daniele

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.

Regards

Kamran

Hi Kamran,
yaou have rigth to sell ......
My mistake ...

Here the new zip ....

GridWithNodes.Zip (93.2 KB)

Excuse me fon my mistake ...

Regards

Daniele

Hi Daniele

Not a problem.
Thats all ok now.
I will play with this code and see what can be achieved.

Thanks again

Kamran