August 28, 2005

serendipitous flash forms

as most of the coldfusion/arcIMS usergroup knows, i have a thing about xml. i don't know why (perhaps too many fast balls to the head, one too many falls off my mountain bike, too much tequila in college, who knows) but whenever i see any complex xml my brain just freezes. try as i might, i just can't seem to get my head around anything but the most simple xml. it got to the point where i ported a whole java library to CFCs just so i wouldn't have to use xml for some GIS applications.

i've been struggling for a week now trying to work with the xml that cftree needs if you use it via remoting (and who wouldn't these days with flash forms in cf7)--yes you have to feed it xml rather than a cfquery, cfform like cfdocument, hides rather a lot complexity from us poor coldfusiuon developers. one of the things i'm trying to do was locate a given node in a cftree. while plowing thru the flex documentation i noticed methods to determine if a node was a branch (had nodes under it) and if that branch was open or closed. what you can programatically get at depends on whether a branch is open or closed. don't take my word, put up a ctree w/a button that does a
onclick="alert(cftreeObj.length);"

and see what you get as you open and close nodes in the tree. to make a long story short, while trying to figure out a way to traverse a cftree i stumbled on a method to open or close a cftree via some simple ActionScript.

<cfsavecontent variable="open">
var theTree=theTree; //cftree name
var i=0;
// prime the pump
var thisNode=theTree.getTreeNodeAt(i);
while (thisNode != undefined){
   if (theTree.getIsBranch(thisNode) && ! theTree.getIsOpen(thisNode)){
         theTree.setIsOpen(thisNode,true);
      }
      i++;
      thisNode=theTree.getNodeDisplayedAt(i);
   }
</cfsavecontent>

<cfsavecontent variable="close">
var theTree=theTree; //cftree name
var i=0;
// prime the pump
var thisNode=theTree.getTreeNodeAt(i);
while (thisNode != undefined){
      if (theTree.getIsBranch(thisNode) && theTree.getIsOpen(thisNode)){
         theTree.setIsOpen(thisNode,false);
      }
i++;
thisNode=theTree.getNodeDisplayedAt(i);
   }
</cfsavecontent>


you can see a simple example here. i imagine you could adapt this to open/close any bits you needed.

0 Comments:

Post a Comment

<< Home