0 Replies Latest reply on Sep 19, 2010 11:38 AM by Karthik Jayaraman

    Populate tree with data

    Karthik Jayaraman Level 1

      I have a service (a java class) which gives the data to be populated in the tree. I will get the data in the actionscript of the corresponding mxml.Now how can i proceed further

       

      1. Create the logic in which i can create a tree from the actionscript with the data

      2. Create a XML data from the service, send it to actionscript and put the data in the dataprovider of the tree

       

      Please tell me the best way and how to do it. I have also referred some examples where i ll see the code like

       

              <mx:XML id="dp">
              <root>
                  <node label="Parent 1">
                      <node label="Child 1" />
                      <node label="Child 2">
                          <node label="Grandchild 1" />
                          <node label="Grandchild 2" />
                      </node>
                      <node label="Child 3" />
                      <node label="Child 4" />
                  </node>
              </root>
          </mx:XML>

       

      and also

       

          <mx:Array id="arr">
              <mx:Object name="One">
                  <mx:children>
                      <mx:Array>
                          <mx:Object name="Two" />
                          <mx:Object name="Three" />
                          <mx:Object name="Four">
                              <mx:children>
                                  <mx:Array>
                                      <mx:Object name="Five" />
                                      <mx:Object name="Six" />
                                  </mx:Array>
                              </mx:children>
                          </mx:Object>
                          <mx:Object name="Seven">
                              <mx:children>
                                  <mx:Array>
                                      <mx:Object name="Eight" />
                                  </mx:Array>
                              </mx:children>
                          </mx:Object>
                          <mx:Object name="Nine" />
                      </mx:Array>
                  </mx:children>
              </mx:Object>
          </mx:Array>
      
          <mx:Tree id="tree"
                  dataProvider="{arr}"
                  labelFunction="tree_labelFunc"
                  width="200" />


      How can i do these from the action script ! Please help !