Hi,
how do I realize a TDBTree with 3 levels and 3 datasets.
First dataset is master of second and second is master of third.
I thougt to realize it with the DBLayout items, but I'm missing there the Detail property.
Any idea?
TDBTree V.2, Master-Detail tree with 3 Datesets (3 levels)
-
- Newbie
- Posts: 7
- Joined: Thu Oct 18, 2007 12:00 am
Hi,
TDBLayouts is the right way. Using db tables from the borland DBDemos:
Be sure to set up the tabels in master/detail relationship:
Build the tree with DBLayout objects. A very basic example:
Regards,
Tom
TDBLayouts is the right way. Using db tables from the borland DBDemos:
Be sure to set up the tabels in master/detail relationship:
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
tCustomers.Close;
tOrders.Close;
tItems.Close;
tOrders.MasterSource := dsCustomers;
tOrders.IndexName := 'CustNo';
tOrders.MasterFields := 'CustNo';
tItems.MasterSource := dsOrders;
tItems.IndexName := 'ByOrderNo';
tItems.MasterFields := 'OrderNo';
tCustomers.Open;
tOrders.Open;
tItems.Open;
end;
Code: Select all
procedure TForm1.ThreeTabelsClick(Sender: TObject);
var tmp : TDBLayout;
begin
With DBTree1 do
begin
Layout.Clear;
with DBTree1.Layout.Add do begin
DataSet := tCustomers; // some table
Fields := 'CustNo;Company';
Format.HorizTextAlign := htaLeft; //add some format
Format.Border.Visible := False;
Format.Font.Color := clBlue;
end;
with DBTree1.Layout.Add do begin
DataSet := tOrders; // detail of tCustomers on CustNo
Fields := 'OrderNo;AmountPaid';
end;
with DBTree1.Layout.Add do begin
DataSet := tItems; // detail of tOrders on OrderNo
Fields := 'ItemNo;PartNo;Qty';
end;
Refresh;
end;
end;
Tom