Board Logo

tree closed when loading page
Mogiin - 1/21/2004 at 09:47 PM

Hello,

I got a question:

When I load my web site , the whole tree and the items are opened.

What must I change in the code so the tree is closed when my web site is loading.


rock - 1/22/2004 at 01:42 PM

By default only root node in the tigra tree appeares as opened.


veloopity - 1/22/2004 at 03:49 PM

> By default only root node in the tigra tree appeares as opened


yes ... and I'd like all menu items to appear opened by default. I don't have many menu items in the current app so it seems to make more sense to have them all opened right at the beginning.

Does anyone know what code changes are necessary to do that? I'm trying to wade through the code and understand it but haven't quite managed yet. :-)

Michael


rock - 1/22/2004 at 05:40 PM

Just set
this.b_opened = true;
instead of
this.b_opened = !this.n_depth;
in the function tree_item (tree.js)


veloopity - 1/22/2004 at 05:47 PM

>Just set
>this.b_opened = true;
>instead of
>this.b_opened = !this.n_depth;

I had already tried this because it looked like the most logical thing; however, the branches of the menu tree aren't opened. The effect of this change is only that the plus symbols change into minus symbols, and that the menu _thinks_ that all branches are open. The effect is _not_ that the branches with all subbranches are actually displayed, as if I had clicked on all plus symbols.
So there must be some more statements to modify.


rock - 1/24/2004 at 12:33 PM

You're right.
You should init all children items of the open node inside it's div tag.


veloopity - 1/28/2004 at 02:06 PM

> You should init all children items of the open node inside it's div tag.


er ... I'd be grateful for more hints ... init them inside the div tag? that would require that I understand the workings of the javascript ... I only have a very limited understanding of it ... if this can be done with just a little code, I'd be grateful if you could post it ...


rock - 1/29/2004 at 12:17 PM

Tigra Tree Menu PRO supports parameter witch allows you to set initial state of the node without any knowledge of javascript.


Iolai - 7/7/2004 at 08:32 PM

I was able to achieve this goal by altering the last line in tree function from
this.a_children.open();
to
this.a_children.open(1);


esm - 1/11/2005 at 09:06 PM

this.a_children.open();

Where did you find this string? I did a search in tree.js but it's not there.


Rikkez - 1/18/2005 at 07:43 AM

Hello,

I got a question:

When I load my web site , the whole tree and the items are opened.

What must I change in the code so the tree is closed when my web site is


esm - 1/18/2005 at 04:54 PM

I would rather know what to do in order to have the tree opened when the page loads.


tdodds - 2/8/2005 at 02:15 PM

Put the following in the tree.js

function expand_all () {
for (var i = 1; i < trees[0].a_index.length; i++) {
var o_item = trees[0].a_index[i];
if (!o_item.b_opened) o_item.open(o_item.b_opened);
}
}

function collapse_all () {
for (var i = 1; i < trees[0].a_index.length; i++) {
var o_item = trees[0].a_index[i];
if (o_item.b_opened) o_item.open(o_item.b_opened);
}
}

... then after you call:

new tree (TREE_ITEMS, tree_tpl);

call:

either to open all or close all - NOTE: if you have a large tree this will use a lot fo client resources to open everything or close everything - can cause the browser to 'hang' or go unresponsive for few moments ...


esm - 2/8/2005 at 03:18 PM

Thanks, I'll try that.


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/