This content has been marked as final. Show 3 replies
I just ran across this issue this week, too. I was trying to create a datagrid of items in which the user could select one or many of and when they click submit, the selected items would be removed from the list. After taking a few different approaches, this is the one I ended up with...
First, I added a bit column to the ArrayCollection that is populating the datagrid. I initially set the bit column to 0 for all items. The bit column will represent whether or not the checkbox is checked.
Then, inside the checkbox itemRenderer, I have a click event that calls a function in the parentDocument and passes the value of the checkbox [checkbox.selected]. The function inside the parentDocument updates the value of the bit column/property in the ArrayCollection. When the user submits the form, I loop over the ArrayCollection and handle only those in which the bit column/property has been changed to 1.
One other thing, I had to add this to the itemRenderer so that there would not be any issues when the user scrolled the list...
// this override is essential for preventing random (un)checking when your DataGrid is scrolled
override public function set data(value:Object):void
// not sure of the details on when or why, but sometimes this method is passed a null value
if(value != null)
super.data = value;
// set itemRenderer's state based on data value
markPaid.selected = value.MarkForPayment;
Hope that helps...
Thanks for answer, but could you please post here the particular functions which have you talked about??? And what is the bit column in array collection? I have an array column collection with particular colums, where have I add this property? Thanks
A dataProvider for a list-based component, like dataGrid, is a collection of "item" objects. These can be of several datatypes, including xml, Object, and custom class.
The "bit column" is simply some property on the item object that can store the value of the checkbox selected property.