2 Replies Latest reply on Oct 16, 2008 12:17 PM by ntsiii

    AdvancedDataGrid as a itemRenderer

      I am trying to make a list menu using advanceddatagrid. What I would like is a 1 column item with a tree control. I have created that. Then when you pull it down it pulls in a data grid below it.

      I have this mxml code:

      <mx:Canvas width="300" height="800" id="outerCanvas" >

      <mx:AdvancedDataGrid rowCount="0" width="100%" height="100%" id="location_list" variableRowHeight="true" dataProvider="{argumentData}" change="handleClick(event);"
      defaultLeafIcon="{null}" >
      <mx:AdvancedDataGridColumn headerText="" width="20"/>
      <mx:AdvancedDataGridColumn dataField="@label" headerText=""/>

      <!--<mx:AdvancedDataGridColumn dataField="key" headerText="Key" width="30"/>
      <mx:AdvancedDataGridColumn dataField="name" id="b_name" headerText="Building Name"/>-->




      and this is my renderer

      <mx:DataGrid xmlns="*" xmlns:mx=" http://www.adobe.com/2006/mxml" showHeaders="false">
      override public function set data(value:Object):void
      dataProvider = value;

      <mx:DataGridColumn dataField="key" headerText="Key" />
      <mx:DataGridColumn dataField="name" headerText="Building Name" />


      what seems to happen is it creates a separate datagrid for each element of the data set. How do I nest the datagrid in so it just displays as a list?

      Here is my compiles swf so you can see what is going on:


      and my xml is here:


      any help would be appreciated. I have banged my head on this one.
        • 1. Re: AdvancedDataGrid as a itemRenderer
          brad_rice Level 1
          I think I figured out how to create my menu from the advanceddatagrid using an itemRenderer. Here it is working:


          I changed the renderer to this:

          <?xml version="1.0" encoding="utf-8"?>

          <mx:HBox paddingLeft="2" xmlns:mx=" http://www.adobe.com/2006/mxml" >
          override public function set data( value:Object ) : void {
          super.data = value;

          <mx:Label text="{data.key}" width="30" />
          <mx:Text width="100%" text="{data.name}" />

          Now, one thing I would like to do is somehow remove the change event on just the top level list items. Right now if you click one of the items you will get some data from the item. However the top level items don't have the data and I don't want the event to fire when you click them. Any thoughts anybody?
          • 2. Re: AdvancedDataGrid as a itemRenderer
            ntsiii Level 3
            In the click handler, test for the top level item and call event.preventDefault()

            Haven't actually done this with a click or itemClick event but it works with the editing events.