Board Logo

One click for expansion of folder
thomaspk - 11/16/2004 at 02:49 PM

Hi all,

I found the following lines somewhere in the forum but I can't find them anymore:



"Hi,

Actually there is a way to prevent root nodes from "rolling up" without changing tree.js. Just define this function in any of the other files.

function rootNoClose() { return false }

Then add this item scope argument to your root nodes.

{'hc':'rootNoClose'}

e.g.
var TREE_ITEMS = [
['Home', 0, {'hc':'rootNoClose'},
['ChildNode_1', 'example.com', //...etc

Now the "Home" node will not close no matter how many times you click on it.

Also, if you add this next function, nodes will only require one click to open.

function onItemSelectHandler (o_item) {
if (o_item.a_children)
o_item.o_root.toggle(o_item.n_id)

return true;
}

Don't forget to add this to your tree_tpl.js file.

'onItemSelect':'onItemSelectHandler'

Enjoy,
Dan"




What I want to acchieve is that if somebody clicks on a folder ONCE that then the folder expands its leafs.

So I tried the following in tree_tpl.js:

function onItemSelectHandler (o_item) {
if (o_item.a_children)
o_item.o_root.toggle(o_item.n_id)

return true;
}

var tree_tpl = {
'target' : 'mainFrame', // name of the frame links will be opened in
// other possible values are: _blank, _parent, _search, _self and _top

'onItemSelect':'onItemSelectHandler',
'icon_e' : 'tree/icons/empty.gif', // empty image ....

But this doesn't work.

As I am a JS-Dummy I'd be happy if somebody tells me step by step what to do.

Thanks

Thomas


rock - 11/18/2004 at 09:59 AM

Are you sure you're using PRO version of the control?


thomaspk - 11/18/2004 at 03:00 PM

No, I'm not using the pro version of the tigra tree menu.

Was this an instruction for pro users or what do you mean by "PRO version of the control"?

Thomas


rock - 11/18/2004 at 03:12 PM

Yes, free version does not supports API, it has open source instead.


thomaspk - 11/23/2004 at 08:54 AM

Does this mean I can not realize this one-click-thing in the free version?

Thomas


rock - 11/23/2004 at 10:34 AM

Try to find sollution inside discussion:
http://www.softcomplex.com/forum/viewthread_1127/


Joaquin - 11/17/2005 at 11:18 PM

Ok, after 2 days of staring at this code, I have finally figured out how to have the nodes expand when you just "single" click on the name of the node not just the "+".

This is my first post so please be gentle.

Inside tree.js you will find a function called "item_init()".

Inside this function you will see a very long "return" statement.

Inside this return statement you will see various events such as onmouseover/onmouseout and then onclick and ondblclick.

example:
ondblclick="trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')"

What you want to do is to highlight and copy everything in between the double quotes after ondblclick=.

What you want to have copied is:
trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')

Now, what you need to do is to paste this code into the event right before "ondblclick", which is "onclick". After the paste add a semicolon and a space before the code that was already there.

What you want is your "onclick" call to look like this:

onclick="trees[' + this.o_root.n_id + '].toggle(' + this.n_id + '); return trees[' + this.o_root.n_id + '].select(' + this.n_id + ')"

So now the node will be selected and open on a single click.


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