EhLib.Com
https://forum.ehlib.com/en/

Grid /Memtable get Parent Nodes Id
https://forum.ehlib.com/en/viewtopic.php?f=5&t=1068
Page 1 of 1

Author:  jedimen [ 20 Jan 2021, 20:19 ]
Post subject:  Grid /Memtable get Parent Nodes Id

Hi,

can i get recursive all parentnodes ID`s up to the Mainnode?

kind regards
christian

Author:  EhLibSupport [ 21 Jan 2021, 08:59 ]
Post subject:  Re: Grid /Memtable get Parent Nodes Id

Hello jedimen

Do you use TMemTableEh.TreeList mode?

Author:  jedimen [ 21 Jan 2021, 11:52 ]
Post subject:  Re: Grid /Memtable get Parent Nodes Id

Yes, im using the TreeMode.

I`m using this code.

Code:
  id := MemTableEh1.FieldByName('id').AsInteger;
  parent := MemTableEh1.FieldByName('parent').AsInteger;
  s := '|' + inttostr(parent) + '|';

  while parent > 1  do
  begin

    for i := 0 to MemTableEh1.RecordsView.MemoryTreeList.AccountableCount-1 do
    begin
      RecView := MemTableEh1.RecordsView.MemoryTreeList.AccountableItem[i];
      id := RecView.Rec.DataValues['id', dvvValueEh];
      if (id = parent) and (parent > 1)   then
      begin
        parent := RecView.Rec.DataValues['PARENT', dvvValueEh];
        if (parent > 1) then s := s + inttostr(parent) + '|';
        break;
      end;

    end;

  end;


Or can I get directly access to a array?

kind regards
christian

Author:  EhLibSupport [ 21 Jan 2021, 13:13 ]
Post subject:  Re: Grid /Memtable get Parent Nodes Id

Hello

Quote:
can i get recursive all parentnodes ID`s up to the Mainnode?


If you have reference to TMemRecViewEh like RecView := MemTableEh1.RecView;
then you can access Parent RecView using property RecView.NodeParent.

you can read information about properties and methods that can be used when working with a tree in the
"<EhLib Archive>\Hlp\ENG\EhLib Users Guide.doc" file in the "Storing records in tree mode (TreeView)" section.

Author:  jedimen [ 21 Jan 2021, 16:27 ]
Post subject:  Re: Grid /Memtable get Parent Nodes Id

Thx

Author:  jedimen [ 21 Jan 2021, 16:47 ]
Post subject:  Re: Grid /Memtable get Parent Nodes Id

Perfect, so much faster!

Code:
procedure TForm1.Button4Click(Sender: TObject);
var
  RecView: TMemRecViewEh;
  s: string;
begin
  RecView := MemTableEh1.RecView;
  while RecView <> MemTableEh1.RecordsView.MemoryTreeList.Root do
  begin
    s:=s + '|'  + VarToStr(RecView.Rec.DataValues['id', dvvValueEh]);
    RecView := RecView.NodeParent;
  end;

  edit1.text := s;
end;

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/