1 Reply Latest reply on Dec 1, 2009 3:07 AM by wurlyOnIce

    AdvancedDataGrid itemrenderer on treecolumn

    wurlyOnIce

      Can someone please help me.

       

      I want to place a itemrenderer on the treecolumn of an advanceddatagrid.

      When i do this, everything works fine, except when i do this, i loose my treeleaf icon for that item, and the text wil be displayed from the beginning of the column instead of the position of the tree depth.

       

      Below a small flex source. In this the column Region is the treecolumn. In this small example i wish the text to be displyed in red. As you can see, it works fine, except there's no tree icon and de text is positioned at the beginning of the column.

       

      Thanks for any help!

       

       

       

      <?xml version="1.0"?>

      <mx:Application

       

      xmlns:mx="http://www.adobe.com/2006/mxml">

       

       

      <mx:Script>

      <![CDATA[

       

      import mx.collections.ArrayCollection;

       

      [

      Bindable]

       

      private var dpFlat:ArrayCollection = new ArrayCollection([

      {Region:

      "Southwest", Territory:"Arizona",

      Territory_Rep:

      "Barbara Jennings", Actual:38865, Estimate:40000},

      {Region:

      "Southwest", Territory:"Arizona",

      Territory_Rep:

      "Dana Binn", Actual:29885, Estimate:30000},

      {Region:

      "Southwest", Territory:"Central California",

      Territory_Rep:

      "Joe Smith", Actual:29134, Estimate:30000},

      {Region:

      "Southwest", Territory:"Nevada",

      Territory_Rep:

      "Bethany Pittman", Actual:52888, Estimate:45000},

      {Region:

      "Southwest", Territory:"Northern California",

      Territory_Rep:

      "Lauren Ipsum", Actual:38805, Estimate:40000},

      {Region:

      "Southwest", Territory:"Northern California",

      Territory_Rep:

      "T.R. Smith", Actual:55498, Estimate:40000},

      {Region:

      "Southwest", Territory:"Southern California",

      Territory_Rep:

      "Alice Treu", Actual:44985, Estimate:45000},

      {Region:

      "Southwest", Territory:"Southern California",

      Territory_Rep:

      "Jane Grove", Actual:44913, Estimate:45000}

      ]);

      ]]>

       

      </mx:Script>

       

       

      <mx:Panel title="AdvancedDataGrid Control Example"

      height="

      75%" width="75%" layout="horizontal"

      paddingTop="

      10" paddingBottom="10" paddingLeft="10" paddingRight="10">

       

       

      <mx:AdvancedDataGrid id="myADG"

      width="

      100%" height="100%"

      initialize="gc.refresh();"

      >

       

      <mx:dataProvider>

       

      <mx:GroupingCollection id="gc" source="{dpFlat}">

       

      <mx:grouping>

       

      <mx:Grouping>

       

      <mx:GroupingField name="Region"/>

       

      <mx:GroupingField name="Territory"/>

       

      </mx:Grouping>

       

      </mx:grouping>

       

      </mx:GroupingCollection>

       

      </mx:dataProvider>

       

       

      <mx:columns>

       

      <mx:AdvancedDataGridColumn dataField="Region">

       

      <mx:itemRenderer>

       

      <mx:Component>

       

      <mx:Text color="0xff0000" text="{data.Region}" />

       

      </mx:Component>

       

      </mx:itemRenderer>

       

      </mx:AdvancedDataGridColumn>

       

      <mx:AdvancedDataGridColumn dataField="Territory"/>

       

      <mx:AdvancedDataGridColumn dataField="Territory_Rep"

      headerText="

      Territory Rep"/>

       

      <mx:AdvancedDataGridColumn dataField="Actual"/>

       

      <mx:AdvancedDataGridColumn dataField="Estimate"/>

       

      </mx:columns>

       

      </mx:AdvancedDataGrid>

       

      </mx:Panel>

       

      </mx:Application>

        • 1. Re: AdvancedDataGrid itemrenderer on treecolumn
          paul.williams Level 4

          The renderer is responsible for displaying the icon, disclosure icon and indentation. So if you create your own renderer from scratch, you will have to code this behaviour yourself.

           

          Rather than reinvent the wheel, I'd recommend extending the AdvancedDataGridGroupItemRenderer and adding your own behaviour. The source code for this class may be daunting, so post-back if you get stuck.