7 Replies Latest reply on May 16, 2009 12:00 AM by bilen_cekic

    ObjectHierarchicalData, Object, Array , ARGHHH :(

    bilen_cekic Level 1

      Hi,

      I implemented ObjectHierarchicalData and wrote some functions, they work great with the source code below,

       

      private var ohd:ObjectHierarchicalData;

       

          private var largeObject:Object =

                  [

                  { "id":"1", "name":"Misc", "type":"parent", "parentTask":"0"},

                  {"id":"2", "name":"Clean the kitchen", "type":"parent", "parentTask":"0"},

                   {"id":"3", "name":"Pay the bills", "type":"parent", "parentTask":"0"},

                  {"id":"4", "name":"Paint the shed", "type":"parent", "parentTask":"1"},

                  {"id":"5", "name":"Get ready for party", "type":"child",

      "parentTask":"1"},

                  {"id":"6", "name":"Do the dishes", "type":"child", "parentTask":"2"},

                  {"id":"7", "name":"Take out trash", "type":"child", "parentTask":"2"},

                  {"id":"8", "name":"Gas Bill", "type":"child", "parentTask":"3"},

                  {"id":"9", "name":"Registration", "type":"child", "parentTask":"3"},

                  {"id":"10", "name":"Fix the car", "type":"parent", "parentTask":"0"},

                  {"id":"11", "name":"New tires", "type":"child", "parentTask":"10"},

                  {"id":"12", "name":"Emissions test", "type":"child", "parentTask":"10"},

                  {"id":"13", "name":"Get new paint", "type":"child", "parentTask":"4"},

                  {"id":"14", "name":"Buy brushes", "type":"child", "parentTask":"4"},

                  {"id":"15", "name":"Buy Drinks", "type":"child", "parentTask":"5"},

                  {"id":"16", "name":"clean living room", "type":"child", "parentTask":"5"},

                  {"id":"16", "name":"finish invitations", "type":"child",

      "parentTask":"5"} ];

       

       

      ohd = new ObjectHierarchicalData(largeObject);

       

         <mx:AdvancedDataGrid id="dg" dataProvider="{ohd}"  width="300" height="200" creationComplete="init()">

      <mx:columns>

                  <!-- all we want to display of the object is the name, the ADG will

                      take care of displaying the parent child relationship -->

                  <mx:AdvancedDataGridColumn dataField="name"/>

              </mx:columns>

          </mx:AdvancedDataGrid>

       

       

       

       

       

      ---------------------------------

       

      well, i want to generate that LargeObject programtically, how can i do that?

      I tried loops and generated some arrays but it doesnt work,

      if i write something like

       

      largeObject[0] =  [{ "id":"1", "name":"Misc", "type":"parent", "parentTask":"0"}];

      ohd = new ObjectHierarchicalData(largeObject);
      it doesnt give error but the grid coldnt display anydata,
      why ?
      How can i programatically generate that data with loops? Because i will get data from a webservice and i want to bind that data.
      thx.