TDBTree Code Parent - Master Detail - sample code

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
DbTree_User123
Newbie
Newbie
Posts: 3
Joined: Mon May 05, 2003 4:00 am

TDBTree Code Parent - Master Detail - sample code

Post by DbTree_User123 » Mon Oct 03, 2011 2:48 pm

I have implemented a TDBTree using one dataset with a code field and a parent field pointing to it.
Similar to TDBTree Wizard sample code (Database Tree Wizard).

Now I would like to add one additional level to the end of the tree based upon a master - detail relationship.

Could you please provide some sample code on how to add this additional level.

Do I have to use Layout?

Sample code:
DbTree1.DataSet := dm_main.qry_tree_structure; // some table
dm_main.qry_tree_structure.Open;
DbTree1.Layout[0].codefield := 'CODE_ID';
DbTree1.Layout[0].Parentfield := 'PARENT_ID';
DbTree1.Layout[0].fields := 'NAME';
DbTree1.Refresh;

The number of levels in the tree is not fixed, for some data you see a total of 4 levels, for some data a total of 5 levels, for some data a total of 6 levels.

Table1.CODE_ID is linked using a master detail relationship to Table2. I would like to display Table2.name one level below the tree end.

Thank you in advance for your reaction.

DbTree_User123
Newbie
Newbie
Posts: 3
Joined: Mon May 05, 2003 4:00 am

Re: TDBTree Code Parent - Master Detail - sample code

Post by DbTree_User123 » Wed Oct 05, 2011 2:16 pm

Good afternoon,

Using Parent / Code relationship Delphi code we solved this issue by changing the SQL - query using UNION ALL.

select ...
from table1
UNION ALL
select ...
from table1, table2
where ... ( join )

Best regards,

Erik

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TDBTree Code Parent - Master Detail - sample code

Post by Yeray » Thu Oct 06, 2011 8:26 am

Hello Erik,

I was going to ask you for more details to understand better your needs, but I'm glad to hear you found how to achieve it.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply