JavaScript.CoolDev.Com Support Forums

Any questions related to JavaScript menu and JavaScript tree menu by Javascript.CoolDev.Com

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COOLjsTree controlling via JavaScript

 
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsTree
Author Message
michael schoettler
Guest





PostPosted: Thu Jun 19, 2003 11:55 pm    Post subject: COOLjsTree controlling via JavaScript Reply with quote

Thanks for COOLjsTree PRO, works fine! but . . .

I am switching between 2 COOLjsTree PRO-trees in the same frame. When switching back, last tree-state should be reestablished but I don't want to use cookies since lots of people don't like them.
This is possible via JavaScript when I put some extra-lines (which I should not!) in your expandNode-function to keep track of the tree-state. Is there any other way to manage my problem? What about event-handling ?

Similar problem with styles: With PRO I have a CSS class for the selected node and when I click a subnode x the content of another frame is changed to 'x' and subnode x is highlighted OK.
When the user then opens/closes another node highlight moves to y which it should not since the other frame still shows 'x'.
So again I have to keep track with some extra-code!?

Thank you.

Sincerely,

M. Schoettler
Berlin, Germany
m.schoettler@t-online.de
Back to top
AlexKunin
Developer


Joined: 03 Jan 2003
Posts: 1191

PostPosted: Sat Jun 21, 2003 12:08 am    Post subject: Reply with quote

1. You can read tree state using following piece of code.
Code:
var state="";
for (var i=0; i < tree.Nodes.length; i++) state +=tree.Nodes[i].expanded ? '1' : '0';

And then you can write state back using this code.
Code:
for (var i=0; i < tree.Nodes.length; i++) if (state.charAt(i)=='1' && tree.Nodes[i].hasChildren()) tree.expandNode(i, true);

Cookies are generally useful feature, and people who don't like cookies should feel some discomfort. And those who really don't like cookies because they treat his/her privacy can tune their browser to allow cookies from your site... Probably, there is not so easy-to-use alternatives to cookies...

2. Yes, you have to keep track with some extra-code because this feature is not yet included into the script (we cannot include all the features that can be done - script will be hundreds of kilobytes in size). You can write this code by yourself or ask technical support to do it for you (jssupport@cooldev.com).
Back to top
michael schoettler
Guest





PostPosted: Sat Jun 21, 2003 4:49 pm    Post subject: COOLjsTree controlling via JavaScript Reply with quote

Hi Alex_Kunin,

Thanks for your Code - works much better than my test-code by checking the existence of parentNodes and then unfolding them one by one . . .
(By the way: With my system "tree.expandNode(i, true)" does not work! "tree.expandNode(i, false)" works fine!)

My second problem with highlighting the correct selected nodes was easily solved by some extra-code in the expandNode- and selectNode-functions to keep track and adding window.setTimeout("select_function()", . . .) to my HTML-page.

Last not least: With your last update of COOLjsTree PRO everything even works with Netscape 7 ! great !!! Very Happy

Thanks a lot

Sincerely,

M. Schoettler
Back to top
AlexKunin
Developer


Joined: 03 Jan 2003
Posts: 1191

PostPosted: Sat Jun 21, 2003 8:31 pm    Post subject: Reply with quote

You are welcome.

About expandNode. Second parameters is boolean value, "true" means "don't redraw" and "false" means "redraw". When there are too many nodes it is better to call expandNode with second paramter set to true, and after all nodes where toggled you only need to call "RedrawAllTrees()" once. This should keep performance at high level.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    JavaScript.CoolDev.Com Forum Index -> COOLjsTree All times are GMT
Page 1 of 1