Your CheckBox itemRenderer is getting recycled after the delete.  Use a
custom itemRenderer for the CheckBox.
http://blogs.adobe.com/aharui/item_renderers/
<http://blogs.adobe.com/aharui/item_renderers/>
-TH
--- In flexcoders@yahoogroups.com, "ilikeflex" <ilikef...@...> wrote:
>
> Hi
>
> I want to remove the row of datagrid. In one of the columns i have
checkbox as item renderer.I select checkbox and i delete the row.But the
challenge, i am facing is that when i remove the row from datagrid, the
next row's checkbox becomes selected which i do not want. How can i
avoid this?? Please see the test case below.
>
> Any pointers are highly appreciated.
>
> Thanks
> ilikeflex
>
> I have a sample test case
> <?xml version="1.0"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
>  <mx:Script>
>   <![CDATA[
>    import mx.controls.DataGrid;
>    import mx.collections.XMLListCollection;
>
>    private var xml:XML=<root>
>      <item>string one</item>
>      <item>string two</item>
>      <item>string three</item>
>      <item>string four</item>
>      <item>string five</item>
>      <item>string six</item>
>     </root>;
>
>    [Bindable]
>    private var xc:XMLListCollection=new XMLListCollection(xml..item);
>
>    public function deleteItem(event:MouseEvent):void
>    {
>     xc.removeItemAt(dg.selectedIndex);
>     xc.refresh();
>    }
>   ]]>
>  </mx:Script>
>  <mx:DataGrid id="dg"
>      dataProvider="{xc}">
>   <mx:columns>
>    <mx:DataGridColumn headerText="String Text"
>           dataField="item">
>     <mx:itemRenderer>
>      <mx:Component>
>       <mx:Text text="{data}"/>
>      </mx:Component>
>     </mx:itemRenderer>
>    </mx:DataGridColumn>
>    <mx:DataGridColumn headerText="Delete Item">
>     <mx:itemRenderer>
>      <mx:Component>
>       <mx:CheckBox label="Delete"
>           click="outerDocument.deleteItem(event)"/>
>      </mx:Component>
>     </mx:itemRenderer>
>    </mx:DataGridColumn>
>   </mx:columns>
>  </mx:DataGrid>
> </mx:Application>
>

Reply via email to