I am facing a weird problem in Flex when I am selecting the multiple
check boxes placed as an itemEditor in the DataGrid.
Here is what I have to do:
select the multiple rows through checkboxes placed as itemEditor and
on clicking the delete button present at the end I want to delete all
the selected rows.
Problem:
On selecting 4 to 5 check boxes immediately one after another few of
the check boxes reset automatically to its original state and when I
click delete button those are not getting deleted.
Please let me know if you have a solution for this problem.
I know that we have a multiple row selection facility available but I
want to do this way only.
Here is the code you can copy paste and check the example.
<?xml version="1.0"?>
<!-- itemRenderers\dataGrid\MainAppEditable.mxml -->
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml" height="700"
width="700">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var initDG:ArrayCollection = new ArrayCollection([
{Confirmed: false, Sent: false},
{Confirmed: false, Sent: false},
{Confirmed: false, Sent: false},
{Confirmed: false, Sent: false},
{Confirmed: false, Sent: false},
{Confirmed: false, Sent: false},
{Confirmed: true, Sent: false}
]);
private function deleteAll():void
{
for (var i:int=initDG.length-1;i>=0;i--)
{
if ( initDG.getItemAt(i).Confirmed == true)
{
initDG.removeItemAt(i);
}
}
}
]]>
</mx:Script>
<mx:DataGrid id="myDG"
width="500" height="250"
dataProvider="{initDG}"
variableRowHeight="true"
editable="true" rowCount="8">
<mx:columns>
<mx:DataGridColumn dataField="Confirmed"
editable="true"
rendererIsEditor="true"
itemRenderer="mx.controls.CheckBox"
editorDataField="selected"/>
<mx:DataGridColumn dataField="Sent"
editable="true"
rendererIsEditor="false"
itemEditor="mx.controls.CheckBox"
editorDataField="selected"/>
</mx:columns>
</mx:DataGrid>
<mx:Button label="Delete" click="deleteAll()"/>
</mx:Application>