House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / ColdFusion Talk (CF-Talk)

ColdFusion MX / FLASH MX - Tree Menu

Author:
Mike Chambers
07/19/2002 01:08 PM

the tree menu has a method called setDataProvider, which takes a data provider class (as do many of the other components). thus you don't have to manually map the recordset data to the tree menu, you just do something like: tree.setDataProvider(recordset); if you have a deeper data structure, then you will have to loop through the data and map it too the tree. mike chambers mesh@macromedia.com > > I've been doing this very thing right at the moment, and > > once you get your head into actionscripting its actually > > quite easy. > > Even once you learn ActionScripting, which can be a beast of > it's own, you > still have to learn Flash Remoting and CFCs.  After you have > the basics down > with that, you'll have to understand recursive functions, > which again, can > be a beast. > > I have not had the chance to really test the following assumptions so > anyone, please let me know if I'm wrong. > > If you don't use recursive functions, you load the data in > one recordset at > a time.  The first recordset is easy because you assign it to the > DataProvider of the RootNode (actually, I would recommend > DataGlue, but > setDataProvider works well too).  Once you want to pull in > the next set of > data for a tree node, you have no reference back to the > original tree node > (unless you create a lookup for your tree).  For example, you > make your call > to the server and when the recordset comes back, you have to > reference to > the parent tree node.  You can find it's ID from the > recordset perhaps, but > there's no "findTreeNodeByID()" function. > > The only other way I could see implementing something like > this without > using a recursive function would be to have the server return > a recordset of > all the nodes, ordered by ParentID and doing this: > > (pseudo-code because I can't remember Recordset syntax off-hand): > > // input is a recordset from the server called "result" > > var rsLkp = new Object(); > var rsTree = new Object(); > > rsTree.ID = 0; > rsTree.ParentID = null;   // not really necessary, but used > for clarity > rsTree.Name = "root node"; > rsTree.arrChildren = new Array(); > > rsLkp[0] = rsTree; > > // loop through recordset and stick nodes into the tree > for(var i=0; i<result.recordcount; i++) { >   // find parentNode from Lookup >   var parentNode = rsLkp[result[i].ParentID]; > >   // find max index of child array in the parent node >   var childIndex = parentNode.arrChildren.length; > >   // set tree node with information >   parentNode.arrChildren[childIndex] = new Object(); >   parentNode.arrChildren[childIndex].ID = result[i].ID; >   parentNode.arrChildren[childIndex].ParentID = > result[i].ParentID; >   parentNode.arrChildren[childIndex].Name = result[i].Name; >   parentNode.arrChildren[childIndex].arrChildren = new Array(); > >   // add node to the lookup >   rsLkp[result[i].ID] = parentNode.arrChildren[childIndex]; > } > > > > Disclaimer: I haven't tried that code, but it looks like it > should work. > (Famous last words)  You could probably change that code > around to assign it > to a Tree component as well. > > > > > > Ben Johnson > >


Search cf-talk

February 11, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29