Here is my dataGrid: How can I get all the selected values of check
<mx:DataGrid id="dg"
dataProvider="{listOfItems}" verticalAlign="middle" rowHeight="20" rowCount="30"
selectable="true" verticalScrollPolicy="on" >
<mx:columns >
<mx:DataGridColumn id="col1"
dataField="value"
headerText="Item Name">
<mx:itemRenderer>
<mx:Component>
<mx:CheckBox label="{data.vlaue}" paddingLeft="5" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
I have a button below that:
<mx:Button x="25" label="Get Selected Items" width="100" click="getSelItems()" cornerRadius="7" fontSize="12" id="itmSel" />
I could find some ways to get the individually selected row by setting change=""
method, but how to get all the selected items.
One simple solution I found so far is, to iterate my dataprovider
checking, if the item is selected
or not.
And here you go!
var tmpList:ArrayCollection = ArrayCollection(dg.dataProvider);
var obj:Object;
for (var i:int=0; i < tmpList.length; i++)
{
if (tmpList[i].Selected == true)
{
//Added to my array collection.
}
}