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: How to Keep Only One Tree Open
Tolstoy
Member

Posts: 13
Registered: 5/25/2006
Member Is Offline
posted on 6/25/2006 at 02:58 AM Reply With Quote
How to Keep Only One Tree Open


My apologies if this is a newbie question; I'm only good enough with javascript to hack others' code and otherwise be dangerous, and I have read the forum looking for an answer.

I have a menu with several trees. This is due to the way I have the menu laid out within a vertical table with sections that are separated. To keep the menu(s) from expanding to a very long depth I would like to configure this so that only one tree is open at a time. I have tried to use the collapse_all() function within a SelectHandler, as well as a typical a href to the function, but nothing causes the trees or any of their nodes to collapse. I am not getting any errors in my Firefox Javascript console so at least I know that it isn't a typo.

Any help would be appreciated.

Lev
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 7/10/2006 at 03:03 PM Reply With Quote

Code:

var tree_tpl = {

... irrelevant part of the template structure skipped ...

'onItemSelect': 'onItemSelectHandler',
'onItemOpen' : 'onItemSelectHandler'


// make sure there is no comma after the last key-value pair
};

function onItemSelectHandler (o_item) {
for (var i = 0; i < TREES.length; i++)
if (i != o_item.o_root.n_id)
collapse_all(i);
return true;
}

// this one is copied from the documentation
function collapse_all (n_index, n_depth) {
var o_tree = TREES[n_index ? n_index : 0];
if (!n_depth) n_depth = 1;
if (!o_tree)
alert("Tree is not initialized yet");
var a_nodes = o_tree.a_nodes;
for (var i = a_nodes.length - 1; i >= 0; i--)
if (a_nodes.n_depth >= n_depth && a_nodes.open)
a_nodes.open(1, 1);
o_tree.ndom_refresh();
}

View User's Profile View All Posts By User U2U Member
ikmps
Junior Member

Posts: 2
Registered: 8/15/2006
Location: Gateshead uk
Member Is Offline
posted on 8/15/2006 at 06:26 AM Reply With Quote

Hi to all
sorry for the question
I am trying to get the code working !!!
am i correct in thinking i add the bottom section to the bottom of the tree_tpl ??

if that is correct then i can't get it to work is there any think else i need to change

Thanks

Paul
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 8/15/2006 at 11:01 AM Reply With Quote

Make sure you use PRO version of the script.
View User's Profile View All Posts By User U2U Member
ikmps
Junior Member

Posts: 2
Registered: 8/15/2006
Location: Gateshead uk
Member Is Offline
posted on 8/16/2006 at 02:08 AM Reply With Quote

Hi

It is the Pro version i am using

Paul
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 8/16/2006 at 10:42 AM Reply With Quote

Ok, then submit a support ticket attaching your code, we'll take a look.
View User's Profile View All Posts By User U2U Member
danedev
Junior Member

Posts: 2
Registered: 10/13/2006
Location: Denmark
Member Is Offline
posted on 10/13/2006 at 06:45 AM Reply With Quote
Using with ASp-demo


Hi

How would I implement that code in the dynamicly generated code, like in demo.asp and tree/items.asp?

Btw: Wonderful product, it was a breeze customizing it for use with my SQL database and structure because of the excellent asp/access-demo! :)

Best regards

Klaus
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 10/13/2006 at 09:04 AM Reply With Quote

The above modifications are in the template structure which is usually in the static file (tree_tpl.js) so there should be no difference if you generate the items structure (tree_items.[php/asp/whatever]) dynamically.
View User's Profile View All Posts By User U2U Member
danedev
Junior Member

Posts: 2
Registered: 10/13/2006
Location: Denmark
Member Is Offline
posted on 10/17/2006 at 04:51 AM Reply With Quote

It was a stupid copy+paste error in the collapse_all function, my mistake.

However, I am not getting the expected behaviour. The onItemSelectHandler fires as expected, but function collapse_all is never fired.

Added the event-handlers to tree_tpl.js
'onItemSelect': 'onItemSelectHandler',
'onItemOpen' : 'onItemSelectHandler'


Added functions onItemSelectHandler and collapse_all to demo.asp (and inserted alerts to make sure they actually fire).

Everything still works as before, and onItemSelectHandler is fired, but collapse_all is never fired.

I have tried just about everything I could think of, but I can't completely comprehend what is going on with the tree/javascript, could you take a look?

Any help will be greatly appreciated. :)

Regards

- Klaus
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 10/17/2006 at 08:41 AM Reply With Quote

collapse_all is called by onItemSelectHandler for the trees other than one generated the event. Since you have only one tree on the page and it's the only source of event, collapse_all is not called at all. It's probably something different that you need. For the one-opened-branch-at-a-time sample see the product documentation.
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