CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

DynaTree: Node Level

by asp » 07 Jul 2014 13:13

Hello!

For some tasks it is necessary to know the level of the particular node. Is it possible now? Or, could you add this attribute to the tree node?
asp
 
Posts: 235
Joined: 06 Dec 2013 11:17
Location: Moscow, Russia

by Alexander Bulei » 07 Jul 2014 15:32

Hi asp,

Please check the attached demo.

We have published the jsGetActiveNode method and added new tree node command "dtnGetLevel" (check comments in demo) in next build.

Best Regards.
You do not have the required permissions to view the files attached to this post.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by asp » 08 Jul 2014 09:01

Thank you!

I've understood how to deal with the level when you have an active node. But how to get the level in OnGetChildrenNode event handler if I, for example, don't want to load nodes having the level more then 3.
asp
 
Posts: 235
Joined: 06 Dec 2013 11:17
Location: Moscow, Russia

by Alexander Bulei » 08 Jul 2014 11:46

Hi asp,

You have two ways to check it:

  • Using the var on server and inc on GetChildrenNodes event.
  • Extend the passed node parameters onLazyRead event:

    delphi code
    procedure TIWForm3.IWAppFormCreate(Sender: TObject);
    begin
    IWCGJQDynaTree1.JQDynaTreeOptions.OnLazyRead.Script:= 'function(dtnode){ dtnode.data.nodeLevel = dtnode.getLevel(); }';
    end;

    procedure TIWForm3.IWCGJQDynaTree1GetChildrenNodes(Sender: TObject; ANodeData: ISuperObject; var AJSon: ISuperObject);
    var
    JSonObj: ISuperObject;
    I: Integer;
    nLvl: Integer;
    begin
    nLvl:= ANodeData.I['nodeLevel'];
    AJSon:= TSuperObject.Create(stArray);
    for I := 1 to 5 do
    begin
    JSonObj:= SO();
    JSonObj.S['key']:= 'childId_' + IntToStr(i);
    JSonObj.S['title']:= 'Child ' + IntToStr(i);
    JSonObj.B['isLazy']:= True; // load children via ajax
    AJSon.AsArray.Add(JSonObj);
    end;
    end;

Best Regards.
Group: Developers | Support Team

  • info [at] cgdevtools.com - General information
  • sales [at] cgdevtools.com - Sales department
  • support [at] cgdevtools.com - Product and Technical Support
User avatar
Alexander Bulei
Site Admin
 
Posts: 3635
Joined: 15 May 2012 08:52
Location: Mealhada, Portugal

by asp » 09 Jul 2014 10:13

Thank you!
asp
 
Posts: 235
Joined: 06 Dec 2013 11:17
Location: Moscow, Russia


Return to JQDynaTree

cron

Who is online

Users browsing this forum: No registered users and 3 guests

Contact Us.