:: Forum >> Version 2 >>

Tree control suggestion

Are there already a methods of the Tree control to ExpandAll and CollapseAll? If not, those might me very handy methods to have. I just ran into a scenario where I would like to initially have all of the children items viewable when the control gets created. And if there isn't a method for these, is there a way to programatically expand or collapse a child node?
It just ocurred to that there is no QuickRef file for the Tree control. I will assume it's on it's way after things settle down a bit.
Jim Hunter
Friday, December 23, 2005
I agree Jim, expand/collapse all would be sweet. I am too new to AW to know the answer though. Happy holidays to all.
Friday, December 23, 2005
Jim, it already exist a way.
try this:
obj.onItemClicked = function(eventrow){
IsExpanded this.getItemTemplate(row).getViewProperty("expanded");
alert(IsExpanded ' ' row);
so as an extension you can execute collapse/expansion programatically:
obj.setViewExpanded(true1);  Everything goes fine if you do it before document.write(obj), but I was not able to expand/collapse by execute on-button-click:
obj.setViewExpanded(false, 1);
note that ros in tree strt with 1 and not 0 -- also tried this no luck .. (sure because the tree is not yet finished)
obj.getItemTemplate(1).setViewProperty("expanded", "false");
Friday, December 23, 2005
Uppps , corection ... it works on all situations.
( I was playinng in controls sample page with lots of obj's).. ;-)
Friday, December 23, 2005
And to expand/collapse the all first-level nodes, you can use:

obj.setViewExpanded(true, x);
Friday, December 23, 2005
carlos: your correct code is
Friday, December 23, 2005
Nope, cause the tree-Items start in 1 , but object array starts in 0
Happy Xmas
Saturday, December 24, 2005
I have not yet tried this but it looks like it could be the solution I am looking for. Thanks Carlos & Sage.
Jim Hunter
Friday, December 30, 2005
Maybe a function that collapse all first-level-nodes (expanding only the one [cell] you clicked ) could help a little more.
Not working with "onItemDoubleClicked".

objtree.onItemClicked = function( eventrow){ 
if (
Friday, December 30, 2005
Very helpful, but I wanted the user to be able to expand/collapse any level node via single click. This seemed to work for me.

obj.onItemClicked = function( event, row){
var state = obj.getViewExpanded(row);
if (state == true) {
obj.setViewExpanded(false, row); }
else {
obj.setViewExpanded(true, row); }
Lorenzo C.
Friday, February 3, 2006

This topic is archived.

Back to support forum

Forum search