Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: Search for and Expand to Node
TXGuy22
Junior Member

Posts: 4
Registered: 1/14/2003
Location: Dallas, TX
Member Is Offline
posted on 1/14/2003 at 06:38 AM Reply With Quote
Search for and Expand to Node


Hello everyone,
I am trying to find a way to enter a value into a text box and have the user click a button in order to find a node in the tree and then expand the tree down to that level. Any ideas?
View User's Profile View All Posts By User U2U Member
Ulukai
Member

Posts: 40
Registered: 11/27/2002
Location: Frankfurt, Germany
Member Is Offline
posted on 1/15/2003 at 03:54 PM Reply With Quote

Hi,

I guess I did not really understand what you wanted to say. But I think your problem is similar to two other threads.
Have a look at "expand single node..." and perhaps at "tree in iframe targeting _parent -- how keep active node expanded?".
CU

Ulukai
View User's Profile View All Posts By User U2U Member
TXGuy22
Junior Member

Posts: 4
Registered: 1/14/2003
Location: Dallas, TX
Member Is Offline
posted on 1/15/2003 at 05:45 PM Reply With Quote

Since my original post I have accomplished almost everything I was after except being able to search through the tree for a specific node. I basically need a search algorythmn to search through the array evaluating the value of a_config[0] for a specified value and then expand the tree to that point.

I now have the ability to expand the tree to whatever point I want by specifying a nodes n_id value, however I have not been able to find a way to search the array for a_config[0] values. I want to be able to search for a particular a_config[0] value, identify that nodes n_id and the pass that to my expander function.
View User's Profile View All Posts By User U2U Member
Ulukai
Member

Posts: 40
Registered: 11/27/2002
Location: Frankfurt, Germany
Member Is Offline
posted on 1/15/2003 at 06:14 PM Reply With Quote

Hi,

ok, now I get what you meant:)
I think the easiest way is to use the tree to go through the array. The easiest way is to add config[0] to a key-value array when creating an item.
Like this: (modify the tree-script)

somewhere out of a function do this:
Code:

var a_nodeEntries = new Array();

in function tree_item add somewhere after assigning the array to this.a_config and after assigning the value to this.n_id

Code:

a_nodeEntries[this.a_config[0]] = this.n_id;


This builds an array like:
{"mytext":1, "myothertext":2}

Make sure to have unique node-texts, otherwise an entry would be overwritten.

The only thing left to get the id of a node is:

var myId = a_nodeEntries["mysearchText"];

Now you can step through the other threads in order to get an idea of how to expand that single node.

Note:
I wrote the above code straight into this forum and did not test it. So there may be errors.

Have fun

Ulukai
View User's Profile View All Posts By User U2U Member
Ulukai
Member

Posts: 40
Registered: 11/27/2002
Location: Frankfurt, Germany
Member Is Offline
posted on 1/15/2003 at 06:18 PM Reply With Quote

Ok, reading through your post again it comes up that you already know how to expand the tree. I think your solution would be a nice supplement to the forum.

CU

Ulukai
View User's Profile View All Posts By User U2U Member
TXGuy22
Junior Member

Posts: 4
Registered: 1/14/2003
Location: Dallas, TX
Member Is Offline
posted on 1/15/2003 at 08:15 PM Reply With Quote

Mission Completed Successfully. I have integrated the script into a team member management app that our distributors use to manage their downlines. Since we are an direct sales company, some of our distributors are inactive or are no long in the program and we have need to display that status in the menu. We also have a need to be able to search the tree for a specific ID and expand the tree to that point and select the node, loading the info for that node in an ajoining frame.

Here is a recap of how what I have done to modify the script to make it work in my app:

1. Written ASP script to dynamically build the tree_items array from an AS/400 database.
2. Added two additional values to the tree_items array for status and unique ID.
3. Added Recursive Toggle function to tree super class.
4. Added Search Array variable populated by tree constructor.
5. Added searchTree function to select node and expand tree to that point.

Here is the details for the above:

1. Written ASP script to dynamically build the tree_items array from an AS/400 database. My database record format is defined in the first half of this ASP page. Database access will be different for everyone, but that is beyone the scope of this forum.
Code:




2. Added two additional values to the tree_items array for status and unique ID. By doing this you have to modify two pieces of code in the tree constructor to keep the script from thinking the additional values are extra child nodes.

Change the following two piece of code in the tree_item function substituting the number of values each tree_item has for n. The default value is 2:
Code:

this.a_config = o_parent.a_config[n_order + (this.n_depth ? n : 0)];
...
for (var i = 0; i < this.a_config.length - n; i++)


3. Added Recursive Toggle function to tree super class. Here I used Ulukai's suggestion for recursive expansion by adding the following code to the constructor tree:
Code:

this.recursivetoggle = function(n_id) {var o_item = this.a_index[n_id]; if(o_item.o_parent!=this){o_item.recursiveopen(o_item.b_opened)}else{this.toggle(n_id);}};

Add this to the tree_item Function:
Code:

this.recursiveopen = item_recopen;

Add the following function anywhere in the script:
Code:

function item_recopen(b_close) {
if(this.o_parent!=this.o_root){
this.o_parent.recursiveopen(b_close);
}
this.open(b_close);
this.select(b_close);
parent.frames[this.o_root.a_tpl['target']].location = this.a_config[1];
}


4. Added Search Array variable populated by tree constructor. Add the following code outside of all functions:
Code:

var sarray = new Array();


5. Added searchTree function to select node and expand tree to that point. Add the following anywhere outside of all other functions:
Code:

function searchTree(i,distID) {
trees.recursivetoggle(sarray[distID]);
}


Add the following form code to your HTML or ASP page where the tree is present:
Code:


Dist #:






Now you can enter a known value for a node into the search form and the script will then select that known value out of the sarray variable and locate the n_id of the node in the tree. It is important that these known values be unique as the n_id will be over written if they are not. We are using the primary key field from our database for this purpose and it work very well. I hope this is helpful to any others that may be looking for a way to do what I have done.
View User's Profile View All Posts By User U2U Member
TXGuy22
Junior Member

Posts: 4
Registered: 1/14/2003
Location: Dallas, TX
Member Is Offline
posted on 1/15/2003 at 08:36 PM Reply With Quote

Here is an update to the searchTree function that contains error handling in case you enter an array key that doesn't exist:
Code:

function searchTree(i,distID) {
if (sarray[distID] != null) {
trees.recursivetoggle(sarray[distID]);
} else {
alert("Distributor ID Not Found");
}
}
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Tigra Tree Menu
Product Demonstrations Live Demos:
Frames targeting
Win help style
Free Download Free Download
Free Download Menu Builders
Online Builder
Product Documentation Documentation:
Documenation Page
Support Forum Technical Support
Support Forum
   
Tigra Tree Menu PRO
Product Demonstrations Live Demos
Multiple Trees
Frames Targeting
Icons and Styles Overloading
Event Handling
Performance Test
Version 1.2 features
Product Documentation Documentation
Documenation Page
Change Log
Support Forum Technical Support
Support Forum
Customer Care System
Order Now ORDER NOW!
Add to Cart
View Cart
 

Go To Top


Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004