naqvia
Member
Posts: 13
Registered: 4/12/2007
Location: USA
Member Is Offline
|
| posted on 5/14/2007 at 09:48 PM |
|
|
search mechanism,
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
Administrator
Posts: 1926
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 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
Member
Posts: 13
Registered: 4/12/2007
Location: USA
Member Is Offline
|
| posted on 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
Administrator
Posts: 1926
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 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
Member
Posts: 13
Registered: 4/12/2007
Location: USA
Member Is Offline
|
| posted on 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
Administrator
Posts: 1926
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 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.
|
|
|