Page 1 of 1

TreeViewItem, href=

PostPosted: 04 Jul 2013 10:19
by itroeger
Hello,
at the moment I am evaluating the TIWCGJQTreeView component
and I wonder if and how it is possible to set the href-value of the TreeNodes.
At the moment it seems that the component sets it to a standard value:
href="http://127.0.0.1:8888/#"

Kind regards
Ingo Tröger

Re: TreeViewItem, href=

PostPosted: 04 Jul 2013 12:24
by Alexander Bulei
Hi itroeger,

Hello,
at the moment I am evaluating the TIWCGJQTreeView component
and I wonder if and how it is possible to set the href-value of the TreeNodes.
At the moment it seems that the component sets it to a standard value:
href="http://127.0.0.1:8888/#"


According to the author of the plugin, you can't set "href" to the node.

What are you trying to do?

Best Regards.

Re: TreeViewItem, href=

PostPosted: 04 Jul 2013 13:34
by itroeger
Hello,

I want to build a kind of filetree to list
files and folders of a WebDAV-Server. When a user clicks onto
a TreeNode the filelink should be executed to show the file in
MS Word for example. Therefore I need different URLs for every TreeNode.

It seems to be possible to insert an additional href-entry (by using the Caption property)
but that has the side effect that the image of the treeview is shown twice.

Kind regards,
Ingo Tröger

Re: TreeViewItem, href=

PostPosted: 04 Jul 2013 15:01
by Alexander Bulei
Hi itroeger,

We have implemented a new property "UserAttributes" in tree node, which allow to storage the user data in html.
Will be released asap.

Just for information, If you have some knowledge of javascript, you can use the property "Script" in each event, for instance OnSelect.Script.

Example to open the link by javascript:

Code: Select all
 window.location.url = 'http://www.cgdevtools.com';


or open in new window:

Code: Select all
 window.open('http://www.cgdevtools.com');


*EDITED: Available from V1.6.0.2618

Best Regards.

Re: TreeViewItem, href=

PostPosted: 15 Jul 2013 14:29
by itroeger
Hello cgdevtools,

with the new property UserAttributes it is not possible to insert a
href attribute. I just get the error message that
you can not use reserved word href


Kind regards,
Ingo Tröger

Re: TreeViewItem, href=

PostPosted: 15 Jul 2013 15:34
by Alexander Bulei
Hi itroeger,

Yes, you can't use these attribute as custom.
If you want add and them get your custom attr, you should do something like this:

1.
delphi code
Attribute:= 'myhref'
Value:= 'http://www.cgdevtools.com/';


2. Add browser param to event

delphi code
with JQTV1.JQEvents.OnSelect do
begin
with BrowserParams.Add do
begin
BrowserScript:= JQTV1.JQTreeViewOptions.UIPlugin.jsGetSelected + '.attr("myhref")';
ServerName:= 'HrefValue';
end;
end;


3. Get your user data

delphi code
var
LMyHref: string;
Begin
LMyHref:= AParam.Values['HrefValue'];
end;


Best Regards.

Re: TreeViewItem, href=

PostPosted: 16 Jul 2013 08:27
by itroeger
Hi cgdevtools,

I have tried to implement your tips but the value which is returned
for the attribute myhref is "undefined". Is there something I am doing wrong?

Kind regards
Ingo Tröger

Code: Select all
procedure TIWFrameTreeView.ProcessCommand(ACommand: Integer; AParams: TStrings = nil);
var
  aCGUserAttribute: TCGUserAttribute;
  i: integer;
begin
  tvTest.JQTreeViewOptions.UIPlugin.PluginActive:= True;
  tvTest.JQTreeViewOptions.ThemesPlugin.PluginActive:= True;
  tvTest.JQTreeViewOptions.HTMLPlugin.PluginActive:= True;

  for i:=0 to tvTest.TreeNodes.Count-1 do
   begin
     aCGUserAttribute:= tvTest.TreeNodes[i].UserAttributes.Add;
     aCGUserAttribute.Attribute:= 'myhref';
     aCGUserAttribute.Value:= 'http://www.dmt.de';
   end;

  with tvTest.JQEvents.OnSelect do
   begin
    with BrowserParams.Add do
     begin
      BrowserScript:= tvTest.JQTreeViewOptions.UIPlugin.jsGetSelected + '.attr("myhref")';
      ServerName:= 'HrefValue';
     end;
   end;
end;

procedure TIWFrameTreeView.tvTestJQEventsSelect(Sender: TObject;
  AParams: TStringList);
var
  LMyHref: string;
begin
  LMyHref:= AParams.Values['HrefValue'];

  ShowMessage(LMyHref);
end;