7 Replies Latest reply on Jul 27, 2009 8:01 AM by zakabalt

    More than one tree in a VBox

    zakabalt

      I have one VBox and I load a tree there. To load the tree I get a String with the xml structure. But now I want to load another tree below the first tree, but if it is the same tree I only want to refresh, not load below the same tree. Something like this

       

      <VBox>

       

      Tree1

      ----------

      Tree2

      ---------

      Tree3

      ---------

      </VBox>

       

      To get the trees I use a String and a identifier to identify the trees. And I want to to put a new tree if the id don't exist and refresh if the tree exist.

       

      Here the code that I have:

       

      private function treeLoadedResult(event:ResultEvent):void {
                 xmlTree = XML(srv.getCarpeta.lastResult.toString());//to get the xml
                 var lista:XMLList= xmlTree.Cuenta;
                 for(var i:Number=0;i<lista.length(); i++)
                 {
                       var tmpTree:XMLList = xmlTree.Cuenta[i].node;
                       newTree.dataProvider = tmpTree;
                      newTree.labelField = "@label";
                      newTree.width = 250;
                     
                       treeVBox.addChild(newTree);
                  }                              
              }

       

      <mx:VBox id="treeVBox" width="100%" height="100%" x="9.1" y="0"/>

       

      Thanks!

        • 1. Re: More than one tree in a VBox
          zakabalt Level 1

          I get this string in  xmlTree = XML(srv.getCarpeta.lastResult.toString());//to get the xml

           

          <?xml version="1.0" encoding="UTF-8"?>
          <Cuentas>

              <Cuenta id="cuenta1" label="cuenta1">
              <node label="INBOX">
                  <node label="Nombre">
              </node>
              </node>
              </Cuenta>

           

          </Cuentas>

           

          For the seconf tree I get:

           

          <?xml version="1.0" encoding="UTF-8"?>
          <Cuentas>
             
              <Cuenta id="cuenta2" label="cuenta2">
              <node label="INBOX2">
                  <node label="Apellido2">
              </node>
              </node>
              </Cuenta>

          </Cuentas>

          • 2. Re: More than one tree in a VBox
            vpxav

            Sorry if I'm wrong, as I am a beginner with flex, but I think you should use a Repeater in your VBox to display the tree.

            Something like

            <mx:VBOX>

                 <mx:Repeater id="treeRepeater" dataProvider=" the provider that defines the number of tree you have ">

                      <mx:Tree ...

             


            Regards

            • 3. Re: More than one tree in a VBox
              zakabalt Level 1

              I don't understand very good who works the repeater that you put there. And in the dataprovider I have to know how many trees I will have? Because I don't know how many trees I will have(in one moment 1, later 4, later 2... I could put a variable but I don't understand very good how can I do the repeater and..).

               

              I get create a dinamic Vbox with X tress, but putting all the xml in one, something like this:

               

              <?xml version="1.0" encoding="UTF-8"?>
              <Cuentas>

                  <Cuenta id="cuenta1" label="cuenta1">
                  <node label="INBOX">
                      <node label="Nombre">
                  </node>
                  </node>
                  </Cuenta>
                 
                  <Cuenta id="cuenta2" label="cuenta2">
                  <node label="INBOX">
                      <node label="Apellido">
                  </node>
                  </node>
                  </Cuenta>

              </Cuentas>

               

              With my treeLoad code I create 2 tress in one Vbox, if the xml document have 3 diferents Cuenta I will create 3 trees. But now I have different xml and I don't how can I do the same.

              • 4. Re: More than one tree in a VBox
                vpxav Level 1

                The repeater will be based on your xml source, so it can have as many trees as you like, and you don't need to know how many...

                Check it here: http://examples.adobe.com/flex3/componentexplorer/explorer.html

                 

                There is an example in Visual Components, Repeater Control

                • 5. Re: More than one tree in a VBox
                  zakabalt Level 1

                  But you're speaking with all the trees in one xml? or in differents? If all the trees are in the same xml file I know how can I do, but if it isn't in the same file (one file per one tree) I don't get. I'm sorry probably you're helping me and saying the correct form but I don't get do what I want.

                  • 6. Re: More than one tree in a VBox
                    vpxav Level 1

                    You have to put all the trees in one xml that is the source of the repeater.

                    • 7. Re: More than one tree in a VBox
                      zakabalt Level 1

                      Ok, the source of the first post do the same than the repeater. But I'm asking about a different xml files trees. I receive the trees in differents xml files. I have to put it all in the same, or exist another way using differents xmls? This is my question.

                       

                      Thanks for your help