Board Logo

search mechanism,
naqvia - 5/14/2007 at 09:48 PM

Hi,

How would one go about adding search capability to the tree. Where and what code needs to be changed,and how will one call it?

-Ammar


tigra - 5/14/2007 at 09:52 PM

In Tigra Tree Menu PRO search functionality is already available via the API. In free version you can implement it on top of the existing script by looping through .a_index array and looking at each tree item.

here are the fragments of the Tigra Tree Menu PRO that provide the search functionality (may need adjustments for free version):

Code:

// find item by caption/link method
this.find_item = function (s_value, b_link) {
var a_items = [];
b_link = b_link?1:0;
for (var i = 0; i < this.a_index.length; i++)
if (this.a_index.a_config[b_link] == s_value) {
a_items[a_items.length] = this.a_index;
}
return a_items;
};
this.find_item_by_key = function (s_key, s_value) {
var a_items = [];
for (var i = 0; i < this.a_index.length; i++)
if (this.a_index.a_config[2][s_key] == s_value) {
a_items[a_items.length] = this.a_index;
}
return a_items;
};
this.find_item_by_state = function (n_mask) {
var a_items = [];
for (var i = 0; i < this.a_index.length; i++)
if (this.a_index.n_state & n_mask) {
a_items[a_items.length] = this.a_index;
}
return a_items;
};


naqvia - 5/14/2007 at 09:57 PM

"In free version you can implement it on top of the existing script by looping through .a_index array and looking at each tree item."

Where and how exactly?


tigra - 5/14/2007 at 10:23 PM

where: "on top of the existing script"
how: "by looping through .a_index array and looking at each tree item"
I even provided the samples how PRO version does this.


naqvia - 5/14/2007 at 10:55 PM

I am just confused about why there are three different return statements? wouldnt just one suffice? my js skills are not that good, btw.


tigra - 5/15/2007 at 03:05 PM

Those are three different methods of the tree (the names of the functions are pretty much self explanatory). BTW: It is not unusual even for single routine to have multiple exit points. Anyway, if you're not comfortable with the coding you should ask a friend to help you or just go for the PRO version of the tree.


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/