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: Tree search & select not functioning
jsuen
Member

Posts: 10
Registered: 12/19/2006
Member Is Offline
posted on 1/14/2007 at 06:28 PM Reply With Quote
Tree search & select not functioning


Hi,

I'm having some problems in getting the select(n_id) function working with a given node id in a defined tree.

A sample of the search function I'd like to use is as follows - for a unique param, select that indexed row within the tree:
function search(param) {
var found = TREES['MyTree'].find_item(param);
alert(found);

TREES['MyTree'].select(found);
}

The find_item invocation works as expected, and displays the correct index of the found node in the alert() line. However, it trips up around the select statement, and I get the following JavaScript error in IE each time:

"Object doesn't support this property or method"

Any help would be greatly appreciated, thanks.

Jon
View User's Profile View All Posts By User U2U Member
tigra
Administrator

Posts: 2049
Registered: 6/17/2002
Location: US, CO
Member Is Offline
posted on 1/14/2007 at 07:18 PM Reply With Quote

you can't call .select() on non-initialized items (those are the items that haven't been displayed at least once after the page loaded). You need to call .open() method on all parents of the item starting from the root level before calling .select(). See the sample in the product documentation for that.
View User's Profile View All Posts By User U2U Member
jsuen
Member

Posts: 10
Registered: 12/19/2006
Member Is Offline
posted on 1/15/2007 at 08:16 PM Reply With Quote

Hi,

Thanks for your help, I have slightly modified the sample openItemByCaption() sample in the documentation given, and was just looking to add it further to behave as though the user clicked on a node (and opened the branch) of a certain item.

At present, the sample code will open the branch with the corresponding node found - is it possible to also have the item selected (i.e. link opened, as though the user themself had clicked on it), for example within:
for (var i = a_parents.length-1; i >= 0; i--)
// check if node or root
if (a_parents.n_state & 48)
a_parents.open();
else
// select() invocation?

Thanks,

Jon
View User's Profile View All Posts By User U2U Member
tigra
Administrator

Posts: 2049
Registered: 6/17/2002
Location: US, CO
Member Is Offline
posted on 1/15/2007 at 08:44 PM Reply With Quote

sure, just call .select() on the found item after the parents opening loop.
View User's Profile View All Posts By User U2U Member
jsuen
Member

Posts: 10
Registered: 12/19/2006
Member Is Offline
posted on 1/16/2007 at 06:04 PM Reply With Quote

Hi,

I'm still a little hazy on calling select() in this function (as to whether the tree or item object version should be used). At the moment the following code:
Code:
function openItemByCaption (s_caption) {
// set to true when debugging the application
var B_DEBUG = false;
var o_tree = (TREES['MyTree']);

// find item with specified caption
var a_item = o_tree.find_item(s_caption);

for(var n=0; n < a_item.length; n++) {
o_item=a_item[n];

// collect info about all item's parents
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--;
}

// open all parents starting from root
for (var i = a_parents.length-1; i >= 0; i--) {
// check if node or root
if (a_parents.n_state & 48)
a_parents.open();
}
o_tree.select(a_item[0].n_id);
}
}

will open the corresponding branch fine, but the select call does nothing (with no Javascript errors returned in the browser).

Cheers,

Jon
View User's Profile View All Posts By User U2U Member
tigra
Administrator

Posts: 2049
Registered: 6/17/2002
Location: US, CO
Member Is Offline
posted on 1/16/2007 at 07:07 PM Reply With Quote

you're calling .select(..) on the tree object. Call it on the item object instead:
o_item.select();
instead of
o_tree.select(a_item[0].n_id);
View User's Profile View All Posts By User U2U Member
jsuen
Member

Posts: 10
Registered: 12/19/2006
Member Is Offline
posted on 1/16/2007 at 07:22 PM Reply With Quote

Hi,

Thanks for this. I've replaced it with the call as you mentioned but it still does not bring up any results (i.e. clicking on the leaf normally will open up a new window, with the link designated to it). Is the select() function meant to simulate this behaviour?

Also, I do not know if it affects it in anyway, but the links I aim to call via select() are further javascript functions (which I can retrieve, but not call).

Cheers,

Jon

Attachment: openItemByCaption_edited.txt (943b)
This file has been downloaded 699 times
View User's Profile View All Posts By User U2U Member
tigra
Administrator

Posts: 2049
Registered: 6/17/2002
Location: US, CO
Member Is Offline
posted on 1/17/2007 at 09:09 AM Reply With Quote

no, select just marks the item as selected. you'll need to redirect the bowser or open the window in your code if this is what you want. You can get the URL associated with the item as o_item.a_config[1] and the target as o_item.a_config[2]['tw']
View User's Profile View All Posts By User U2U Member
jsuen
Member

Posts: 10
Registered: 12/19/2006
Member Is Offline
posted on 1/17/2007 at 09:24 PM Reply With Quote

Thanks for your help. For some reason I always assumed select() would emulate the user clicking on the particular branch/leaf!
A:
Code:
window.location.href=o_item.a_config[1];
did the trick perfectly.

Cheers,

Jon
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Product Page
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