3 Replies Latest reply on Mar 8, 2012 6:21 AM by debracey

    Issue with ItemRenderer and MX Datagrid




      I have an item renderer tied to an mx:DataGrid column. The renderer used to be inline with the column, but I've moved it out to its own file so I can reuse it across multiple tables. When the renderer was inline, the items displayed would shrink as the column width decreased -- to the point where if the item could not fit, (ie. column width very small) it would just disappear "beneath" the column.


      After moving the renderer to it's own file -- the renderer doesn't resize (grow/shrink) when the column is resized. So if the user makes the column very small, the contents displayed by the renderer just eat up space and show up over top other columns Any ideas how to make this work?



      Code for Item Renderer:



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

          <s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"




                    <mx:HBox verticalScrollPolicy="auto" horizontalScrollPolicy="off" width="100%">

                              <mx:Spacer top="0" bottom="0" width="4" />

                              <mx:Image id="typeIcon" buttonMode="false" source="{data.type}" />





      Code for column using that renderer:



          <mx:DataGridColumn headerText="Type" dataField="type" itemRenderer="com.myCompany.myProject.TypeRenderer" />


      Posted on Stack Overflow for those who'd like credit for the answer: http://stackoverflow.com/questions/9608241/itemrenderer-doesnt-resize-with-datagrid-column





      Adding `width=100%` to the MXDataGridItemRender element didn't work.