Multiple itemEditor checkbox selection problem

117 views
Skip to first unread message

Kaleem

unread,
Feb 13, 2008, 6:22:32 AM2/13/08
to Flex India Community
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>

Vinod M Jacob

unread,
Feb 13, 2008, 6:59:38 AM2/13/08
to Flex India Community
Hi-

I just tried your code and its working fine..

I selected the first five and deleted and it got deleted......
What is the problem ? Didn`t you mean this?

Kaleem

unread,
Feb 13, 2008, 8:36:50 AM2/13/08
to Flex India Community
Immediately one after the another the data editorDataField tied to
dataField of DataGrid is not getting updated.
Means even after clicking the 5 checkboxes I will getting status that
only 3 or 4 are selected and the data is not reflecting in
ArrayCollection.
> > </mx:Application>- Hide quoted text -
>
> - Show quoted text -

Kaleem

unread,
Feb 13, 2008, 9:27:06 AM2/13/08
to Flex India Community
Oops sorry here is the problem statement:

If we immediately select the checkbox one after the another the data
editorDataField which is tied to dataField of DataGrid is not getting
updated.

And some check boxes change there state when I am clicking out side of
the Grid.

Run the example and click the checkboxes one after the another without
clicking anywhere else, the bindable array collection doesn't update
its field based on the checkbox 'selected' status.
> > - Show quoted text -- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages