kikcontains
Junior Member
Posts: 6
Registered: 9/6/2006
Member Is Offline
|
| posted on 9/6/2006 at 01:33 AM |
|
|
searching caption with regular expressions in the api openItemByCaption
i downloaded the api openItemByCaption from the examples API page.
It's works fine, but this function only returns ok when it founds a exact match. It's possible found it using a regular expression like "01-01*"
or "*eating*"?
Thanks
|
|
|
tigra
Administrator
Posts: 1907
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 9/6/2006 at 11:32 AM |
|
|
the embedded function does exact match only, but you can define own search function externally. Here is the sample:
[code]
function setTree (s_caption) {
var o_tree = trees[0],
o_item;
for (var i = 0; i < o_tree.a_index.length; i++)
if (o_tree.a_index[i].a_config[0] == s_caption) { // that's where you make the change
o_item = o_tree.a_index[i];
break;
}
if (!o_item)
return alert('item ' + s_caption + ' not found');
// following code opens the parents and selects found item
var n_id = o_item.n_id,
n_depth = o_item.n_depth,
a_index = o_item.o_root.a_index,
a_parents = [o_item];
while (n_depth) {
if (a_index[n_id].n_depth < n_depth) {
a_parents[a_parents.length] = a_index[n_id];
n_depth--;
}
n_id--;
}
for (var i = a_parents.length - 1; i >= 0; i--)
// check if node or root
if (a_parents[i].a_children) {
a_parents[i].open();
}
o_item.select();
}
[/code]
|
|
|