TDBTree V.2, Master-Detail tree with 3 Datesets (3 levels)

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
PascalKlaus
Newbie
Newbie
Posts: 7
Joined: Thu Oct 18, 2007 12:00 am

TDBTree V.2, Master-Detail tree with 3 Datesets (3 levels)

Post by PascalKlaus » Mon Dec 10, 2007 7:59 am

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?

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Tue Jan 15, 2008 12:34 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:

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;
Build the tree with DBLayout objects. A very basic example:

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;
Regards,
Tom

Post Reply