tags:

views:

55

answers:

2
var google:Array = datagridID.selectedIndices;

Now is this equal to the one below.

var google:Array = ["0","1", "2"];

My problem is the above one its not taking as array, but when i define it like this it does.

Alert.show(google) gives me 0,1,2

for each(var i:String in google) {
Alert.show(dg.selectedItems[i]["member_id"]);
}

The above code yeilds me only one value.

+1  A: 

You made a typo. It should be datagridID.selectedIndices

It is the same, both are arrays. And I tested it and both should work. Hold CTRL and select a few lines in a datagrid and he should have an array of all the lines you selected. Always adding the last selected in front of the others. And why using google as variable name? It is not very describing what is inside the array.

Arno
When i alert, i am getting as 0,1,2 in a single window...
check my updated code.
+2  A: 

Why first use the array of selectedIndexis and than use the array of selectedItems? Just use the array of selectedItems right away like this

for each(var item:Object in this.dataGrid.selectedItems){
 trace("Item: "+ ObjectUtil.toString(item));
}

In your case you can say:

for each(var item:Object in dg.selectedItems) {
 Alert.show(item["member_id"]);
}

And if you want the last selected item in the datagrid you do

Alert.show(dg.selectedItems[0]);

if you want the last item in the array of selected items you can do this

Alert.show(dg.selectedItems[dg.selectedItems.length -1]);
Arno
You made my day man... Thanks a lot