JavaScript.CoolDev.Com Support Forums

Any questions related to JavaScript menu and JavaScript tree menu by Javascript.CoolDev.Com

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Searching and setting th focus

 
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsMenu
Author Message
raj
Guest





PostPosted: Fri Jul 25, 2003 11:12 am    Post subject: Searching and setting th focus Reply with quote

Hi,
I would like to know how i can search for a value in my tree. Once the result is found i would like the tree to be expanded and the focus set on the node which is found. In case more than oone result is found for the search condition, i want the first to be selected
Back to top
Gala
Support Team


Joined: 21 Jul 2003
Posts: 12

PostPosted: Mon Jul 28, 2003 9:31 pm    Post subject: Reply with quote

Yes, you can find certain node. You can find specific node object by it's caption, URL, or ID. We have three functions which make it possible:
Code:
tree1.nodeByName(caption)
tree1.nodeByID(id)
tree1.nodeByURL(url)

(Instead of "tree1" you should insert variable name that contains reference to your tree.)
All these functions return node object. The most useful thing in it is its "index" field. You can pass this index to functions "expandNode()" and "selectNode()" for the tree will expande and the focus will set on the node which is found, for example:
Code:
// Initialization code:
var tree1 = new COOLjsTreePRO(...);
...
var node = tree1.nodeByName("Home");
if (node) tree1.expandNode(node.index);

Also there is field "expanded" - boolean flag which is set to true when
node is expanded and to false otherwise.

Input parameters for these functions - nodeByName, nodeByURL, nodeByID - correspond to several fields in the tree structure from your tree_nodes.js (field 'id' is optional - it can be ommited):
Code:
[{'id':56}, 'Caption 1', 'url_1.html', 'target_frame'...

So, to find this node in the tree you can call functions mentioned above:
Code:
var node = tree1.nodeByName('Caption 1');
var node = tree1.nodeByID(56);
var node = tree1.nodeByURL('url_1.html');

Good luck!
Back to top
Display posts from previous:   
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsMenu All times are GMT
Page 1 of 1