Page 1 of 1
How to get the selected node ?

Posted:
27 Nov 2015 18:25
by Davide
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
Re: How to get the selected node ?

Posted:
27 Nov 2015 18:27
by Alexander Bulei
Hi,
If you have checkbox's :
- Code: Select all
DynaTree.SelectedNodes
Best Regards.
Re: How to get the selected node ?

Posted:
12 Dec 2015 12:20
by Davide
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
Re: How to get the selected node ?

Posted:
12 Dec 2015 17:12
by assapan
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;
Re: How to get the selected node ?

Posted:
14 Dec 2015 10:20
by Alexander Bulei
Hi Davide,
What version of cgdevtools do you have?
ItemsByUniqueName
This method will return the TIWCGJQDynaTreeNode.
Best Regards.
Re: How to get the selected node ?

Posted:
16 Dec 2015 16:31
by Davide
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
Re: How to get the selected node ?

Posted:
16 Dec 2015 17:04
by Alexander Bulei
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.
Re: How to get the selected node ?

Posted:
17 Dec 2015 16:58
by Davide
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
Re: How to get the selected node ?

Posted:
17 Dec 2015 18:33
by Alexander Bulei
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.