0 Replies Latest reply on Aug 11, 2008 6:07 AM by whertzing

    Need help with e4x syntax for children in ADG TreeView column

    whertzing
      I would like to display Hierarchical XML data as a treeView in a ADG control. I can bind the first (parent) level of my XML to the ADG using a HierarchicalData Dataprovider, but I can't figure out the syntax to get the children.

      The attached code shows the function where the XML is received, and evaluated one level deep. The var "eventdefs" is the ..Group nodes of the XML, and the declaration of the ADG. The ADG binds the eventdefs as hierarchical data, and specifies one column with the datafield as @eventgroup. This works fine and shows the top level nodes.

      I have specified Event as the childrenfield, but I don't see anything in the data grid - nor do I understand how to specify a different value of datafield for the second level of nodes.

      I want to show the value of the attribute "eventgroup" on parent nodes, and show the value of the attribute "description" next to the child nodes. Can this be specified in the mxml? Or do I need a label function, or something else?

      TIA!

      Here is my XML document:
      <list>
      <Group eventgroup="">
      <Event uniqueid="63" description="Error:enter valid Email Address " displayorderingroup="60" displayorder="86" />
      <Event uniqueid="64" description="Error:unable to find account for email address " displayorderingroup="61" displayorder="87" />
      </Group>
      <Group eventgroup="CEP Events">
      <Event uniqueid="244" description="CEP:EveryHit; " displayorderingroup="242" displayorder="253" />
      </Group>
      </list>

      <mx:Script>
      <![CDATA[
      [Bindable("eventDefsChanged")]
      private var _eventDefs:Object;
      public function set eventDefs(m:Object):void
      {
      // We expect m to be a XML document, with "Group" as the name of the highest level (parent) nodes
      _eventDefs = m..Group;
      adg_es.dataProvider = eventDefs;
      adg_es.validateNow();
      dispatchEvent( new Event( "eventDefsChanged" ) );
      }
      public function get eventDefs():Object
      {
      return _eventDefs;
      }
      ]]>
      </mx:Script>

      <mx:AdvancedDataGrid id = "adg_es" displayItemsExpanded="true">
      <mx:dataProvider>
      <mx:HierarchicalData id ="hd" source = "{new HierarchicalData(eventDefs)}" childrenField="Event"/>
      </mx:dataProvider>
      <mx:columns>
      <mx:AdvancedDataGridColumn dataField="@eventgroup"/>
      </mx:columns>
      </mx:AdvancedDataGrid>