4 Replies Latest reply on Jun 30, 2010 5:36 PM by bocode3

    itemrenderer in datagrid

    bocode3

      i've the following datagrid code:

       

      <mx:DataGrid  id="empdg"

        dataProvider="{employeeService.lastResult.employees.employee}"

        width="40%" editable="true"

      itemClick="addRow(event)">

      <mx:columns>

      <mx:DataGridColumn headerText="Reportees" editable="false" itemRenderer="components.empname" width="40"/>

      </mx:columns>

       

      </mx:DataGrid>

       

       

      the components.empname code is follows:

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

       

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

      xmlns:s="library://ns.adobe.com/flex/spark"

      xmlns:mx="library://ns.adobe.com/flex/mx"

      autoDrawBackground="true">

      <mx:HBox>

      <mx:Image source="http://abc.com/add.png"/>

      </mx:HBox>

      </s:MXDataGridItemRenderer>

       

       

      addrow method (in the datagrid) adds a new row when clicked on the column. i would like to change the image source in the above code dynamically to point to "delete.png" with the first column in the first row still pointing to add.png but first column in the second row pointing to delete.png (and so on). As of now when ever new row gets added, it comes with add.png in the first column of the new row...i want to replace this with delete.png.

       

      something like this:

       

      +
          -
          -

       

      Can somebody help?

       

      Thank you

      Bo