| Author |
Message |
OMS_Fred
Joined: 14 Dec 2004 Posts: 3
|
Posted: Wed Oct 19, 2005 11:54 am Post subject: How to create search for a tree? |
|
|
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
|
Posted: Tue Oct 25, 2005 7:06 pm Post subject: |
|
|
Yes, it is possible. You need to use this function:
| Code: | | nodeByName(caption) |
The you need to select needed node with this functions:
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
|
Posted: Wed Oct 26, 2005 11:16 am Post subject: |
|
|
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
|
Posted: Thu Nov 03, 2005 8:19 pm Post subject: Tree Search Function |
|
|
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
|
Posted: Sat Apr 29, 2006 12:05 am Post subject: |
|
|
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
|
Posted: Tue May 02, 2006 8:00 pm Post subject: CoolTreePro Search Method |
|
|
Thank you. I have already developed a search function which is working fine.
Regards, JEK |
|
| Back to top |
|
 |
|