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 

How to create search for a tree?

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    JavaScript.CoolDev.Com Forum Index -> COOLjsTree
Author Message
OMS_Fred



Joined: 14 Dec 2004
Posts: 3

PostPosted: Wed Oct 19, 2005 11:54 am    Post subject: How to create search for a tree? Reply with quote

I have a rather large list of links in a COOLjsTree implementation and my users are asking for a way to do a search of the the tree to find links. I looking for a way to provide this search by any means possible. I have searched this forum but have not found anything helpful. We are running COOLjsTree Version 2.7 Professional.

ANY help would be appreciated.

Fred Simmler
Back to top
Victor_Chuiko
Support Team


Joined: 12 Apr 2005
Posts: 145

PostPosted: Tue Oct 25, 2005 7:06 pm    Post subject: Reply with quote

Yes, it is possible. You need to use this function:
Code:
nodeByName(caption)

The you need to select needed node with this functions:
Code:
selectNode(index)

You can read about this functions in the documentsation tah comes with COOLjsTree Professional.
Back to top
OMS_Fred



Joined: 14 Dec 2004
Posts: 3

PostPosted: Wed Oct 26, 2005 11:16 am    Post subject: Reply with quote

Thank you for the starting point and I will try to implement it from here but it would be more clear to me and anyone finding this thread in the future if there were some sample code available. Can you show me a simple implementatioin?
Thank you,
Fred
Back to top
JamesKafka



Joined: 12 Oct 2005
Posts: 6

PostPosted: Thu Nov 03, 2005 8:19 pm    Post subject: Tree Search Function Reply with quote

Dear COOLjs Support,

I too have requirements to build a search feature for the tree. The user wants to supply a string of characters "abc" and have a list displayed of all the node (captions) that match these leading charaters.

I see you have a method "nodeByName (caption)", which returns the first occurence, however it is unclear how to continue to search for other nodes. As long as I understand how to continue the search, I should be able to build the javascript to iterate through the entire tree. Can you tell me how to continue the search?

Here's the (pseudocode) logic I'm working on:

var results = new Array ();
var index = 0;
var node = tree1.getRoot ();

while (more nodes to search) {
node = node.nodeByName (caption);
if (node != end of tree) {
results [index] = node;
index++;
} else {
set end of tree flag
}
}

This logic assumes that starting at the last node found, will continue the search. If this works, you should end up with a list of nodes matching the caption supplied.

From there you can get the indexes for each node and expand the tree to any node selected from the search results.

Can I supply a RegExp object as an argument and get an array of nodes returned?
Back to top
AlexKunin
Developer


Joined: 03 Jan 2003
Posts: 1191

PostPosted: Sat Apr 29, 2006 12:05 am    Post subject: Reply with quote

Guys, all nodeByXXX functions described in our docs can accept RegExp object as their argument.

Let me know if you need clearer answer.
Back to top
JamesKafka



Joined: 12 Oct 2005
Posts: 6

PostPosted: Tue May 02, 2006 8:00 pm    Post subject: CoolTreePro Search Method Reply with quote

Thank you. I have already developed a search function which is working fine.

Regards, JEK
Back to top
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    JavaScript.CoolDev.Com Forum Index -> COOLjsTree All times are GMT
Page 1 of 1