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: using reset_state in Tigra Tree Pro
bill.smith
Junior Member

Posts: 3
Registered: 8/5/2005
Member Is Offline
posted on 8/5/2005 at 02:23 PM Reply With Quote
using reset_state in Tigra Tree Pro


Hi. I have Tigra Tree Pro. Works great at displaying a tree.

I am trying to use the reset_state function, and I don't have a clue how to do it. My page has:

<script language="JavaScript" src="tree/tree.js"></script>
<script language="JavaScript" src="tree/tree_tpl.js"></script>
<script language="JavaScript">var TREE_ITEMS = [ blah, blah, blah ]</script>

<script language="JavaScript">
new tree (TREE_ITEMS, TREE_TPL);
</script>

How and where do I use the reset_state function?
View User's Profile View All Posts By User U2U Member
rock
Moderator

Posts: 687
Registered: 4/15/2003
Member Is Offline
posted on 8/5/2005 at 02:32 PM Reply With Quote

It depends on what are you tring to do.
Following example kills all saved tree states and opens all roots items after reload:
var tree_tpl = {

....

'beforeInit':'killTreeStates',
'afterInit':'opentoDepth'
// make sure there is no comma after the last key-value pair
};

function killTreeStates(o_tree){
o_tree.o_root.reset_state(); //reset open/close/selected states of the tree
return true;
}

function opentoDepth(o_item){
if(o_item.a_children && o_item.n_depth<0) //n_depth<0 - open roots; n_depth<1 - open roots and first level nodes, etc.
for(var i=0; i<o_item.a_children.length; i++){
o_item.a_children[i].open() // open item
opentoDepth(o_item.a_children[i]) //recursive call
}
}
View User's Profile View All Posts By User U2U Member
bill.smith
Junior Member

Posts: 3
Registered: 8/5/2005
Member Is Offline
posted on 8/5/2005 at 02:45 PM Reply With Quote

Hi.

Thanks for the quick response. I would like to reset the tree state to the default some of the time. I really don't understand your answer at all.

What I would like to do is something like:

<script language="JavaScript" src="tree/tree.js"></script>
<script language="JavaScript" src="tree/tree_tpl.js"></script>
<script language="JavaScript">var TREE_ITEMS = [ blah, blah, blah ]</script>

<script language="JavaScript">
new tree (TREE_ITEMS, TREE_TPL);
if ( a > b ) {
<reset the tree state to the default>
}
</script>
View User's Profile View All Posts By User U2U Member
rock
Moderator

Posts: 687
Registered: 4/15/2003
Member Is Offline
posted on 8/5/2005 at 03:32 PM Reply With Quote

Ok, try to modify your tree_tpl.js file like:
var tree_tpl = {

....

'beforeInit':'killTreeStates',
'afterInit':'opentoDepth'
// make sure there is no comma after the last key-value pair
};

function killTreeStates(o_tree){
if(a > b) {//need reset_state
o_tree.o_root.reset_state(); //reset open/close/selected states of the tree
return true;
}
}


function opentoDepth(o_item){
if(a > b) {//need reset_state
if(o_item.a_children && o_item.n_depth<1) //n_depth<0 - open roots; n_depth<1 - open roots and first level nodes, etc.
for(var i=0; i<o_item.a_children.length; i++){
o_item.a_children[i].open() // open item
opentoDepth(o_item.a_children[i]) //recursive call
}
}
}
}
View User's Profile View All Posts By User U2U Member
bill.smith
Junior Member

Posts: 3
Registered: 8/5/2005
Member Is Offline
posted on 8/5/2005 at 03:45 PM Reply With Quote

Thanks Rock!

That is what I was looking for.
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