3.2.0

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
December 23,
I agree Jim, expand/collapse all would be sweet. I am too new to AW to know the answer though. Happy holidays to all.
Tony
December 23,
Jim, it already exist a way.
try this:
obj.onItemClicked = function(event, row){
var IsExpanded = this.getItemTemplate(row).getViewProperty("expanded");
alert(IsExpanded + ' ' + row);
 }

so as an extension you can execute collapse/expansion programatically:
obj.setViewExpanded(true, 1);


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");
HTH
Carlos
December 23,
Uppps , corection ... it works on all situations.
( I was playinng in controls sample page with lots of obj's).. ;-)
Carlos
December 23,
And to expand/collapse the all first-level nodes, you can use:

for(x=0;x<tree[0].length;x++){
obj.setViewExpanded(true, x);
}
Carlos
December 23,
carlos: your correct code is
for(x=1; x<=tree[0].length; x++){
obj.setViewExpanded(true, x);
}
Sage
December 23,
Nope, cause the tree-Items start in 1 , but object array starts in 0
;-)
Happy Xmas
Carlos
December 24,
I have not yet tried this but it looks like it could be the solution I am looking for. Thanks Carlos & Sage.
Jim Hunter
December 30,
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( event, row){ 
if (tree[0][row-1]==row){
for(var x=0; x<=tree[0].length; x++){  
objtree.setViewExpanded(false, x);  
 }
 objtree.setViewExpanded(true, row); 
 }
  }
Carlos
December 30,
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.
February 3,

This topic is archived.

See also:


Back to support forum