CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

How to get the selected node ?

by Davide » 27 Nov 2015 18:25

Hello,
I filled up a JQDynaTree following the demo code.
Reading the forum I understood that in onActivate event the nameKey I found in AParams is the unique name of the node.

I need to get the selected node when I press a button on my form.
I try the MyDynaTree.Nodes.ItemsByUniqueName function using the "key" value I set in the OnGetRootNodes and OnGetChildrenNodes procedure but I always retrieve a nil.

What is the right way to get the selected node ?

Thank you,
Davide
Davide
 
Posts: 150
Joined: 14 Oct 2013 11:33

by Alexander Bulei » 27 Nov 2015 18:27

Hi,

If you have checkbox's :

Code: Select all
DynaTree.SelectedNodes


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 Davide » 12 Dec 2015 12:20

Hello Alexander,

thanks for your response but my need is different.
I can get the selected "UniqueName" using the "nodeKey" value stored in AParams of the Activate event but I need to know if the selected node is a folder through its "isFolder" property.
Is there a way to get the TIWCGJQDynaTreeNode selected object ?
The ItemsByUniqueName seems the only function that should return a TIWCGJQDynaTreeNode but it always return nil.

Do you have any advice about ?

Thank you,
Davide
Davide
 
Posts: 150
Joined: 14 Oct 2013 11:33

by assapan » 12 Dec 2015 17:12

Hi Davide,
Here is the code i use in OnClick event but you can act the same don't you ?

Code: Select all
procedure TFrameParametresNlu.dtCategoriesJQDynaTreeOptionsClick(Sender: TObject; AParams: TStringList);
var
  Nk: string;
  Node: TIWCGJQDynaTreeNode;
begin
  Nk := AParams.Values['nodekey'];
  Node := dtCategories.Nodes.ItemsByUniqueName[Nk];
  SelectionNode(Node);
end;
Want to visit Ardeche http://leclosdelarc.fr/index.php
The Pont d’Arc Cavern http://en.cavernedupontdarc.fr
Image
User avatar
assapan
 
Posts: 600
Joined: 16 Dec 2013 12:04
Location: France

by Alexander Bulei » 14 Dec 2015 10:20

Hi Davide,

What version of cgdevtools do you have?

ItemsByUniqueName


This method will return the TIWCGJQDynaTreeNode.

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 Davide » 16 Dec 2015 16:31

Hello,

I'm using Delphi 10, IW 14.0.46 and CGIWJQuery 2.8.0.166.
I made some tests coding in OnClick and OnActivate but the call to ItemsByUniqueName always result nil.

Regards,
Davide
Davide
 
Posts: 150
Joined: 14 Oct 2013 11:33

by Alexander Bulei » 16 Dec 2015 17:04

Hi Davide,

OnGetRootNodes and OnGetChildrenNodes


I have notice that you're using the dynamic data.
ItemsByUniqueName search in collection, so in your case, you can't use this method.
What do you want to do with TIWCGJQDynaTreeNode item?

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 Davide » 17 Dec 2015 16:58

Hello,

I just need to know if the selcted node is a folder.
What you noticed is true, I'm using dynamic data.
I believe since the nodes I can select were already loaded, when I can select one of them, they could be retrieved by "ItemsByUniqueName" function.

Regards,
Davide
Davide
 
Posts: 150
Joined: 14 Oct 2013 11:33

by Alexander Bulei » 17 Dec 2015 18:33

Hi Davide,

You have to use the BrownserParams.
Here you have the simple example:

delphi code
procedure TIWForm10.IWAppFormCreate(Sender: TObject);
begin
with IWCGJQButton2.JQButtonOptions.OnClick.BrowserParams.Add do
begin
ServerName:= 'activeNodeIsFolder';
BrowserScript:= IWCGJQDynaTree1.jsGetActiveNode(False) + '.data.isFolder';
end;
end;

procedure TIWForm10.IWCGJQButton2JQButtonOptionsClick(Sender: TObject; AParams: TStringList);
begin
WebApplication.ShowMessage( AParams.Values['activeNodeIsFolder'] );
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


Return to JQDynaTree

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.