tags:

views:

220

answers:

1
[Bindable]
public var groupsList:ArrayCollection;

public function groupListRH(event:ResultEvent):void
{ 
     groupsList=event.result as ArrayCollection;       
}

<mx:ComboBox dataProvider="{groupsList}" 
             labelField="groupName"
             id="grpLst"  width="150"
             prompt="Select one group "                                   
             close="selectedItem=ComboBox(event.target).selectedIndex"               
             focusIn="init();" /> 

<mx:LinkButton label="New Group" id="creatgrp" click="addNewGroup();"/>

Here am getting array of groups(groupName,GroupID each row ) from a RemoteObject and displaying in a ComboBox. I am selecting the groups with selectedIndex as 0,1,2,3, but I want my groupIDs of correspoding groupnames,which am bringing to client side.

How can I get actual the groupId of the selected group?

+1  A: 

You should be able to get it like so:

grpLst.selectedItem.GroupID;

EDIT

Or from within an mx.events.ListEvent.CHANGE handler attached to the ComboBox:

event.target.selectedItem.GroupID

EDIT

Ah, the code formatting has been updated and its easier to read. I see you are using the close event, and setting a variable called selectedItem to the selectedIndex property of the ComboBox. You could just change it so that the variable selectedItem actually references the selectedItem propterty of the ComboBox like so:

selectedItem=(event.target as ComboBox).selectedIndex;
// Then get the GroupID from the selectedItem
selectedGroupID = selectedItem.GroupID

Or just use the index to get the data from the dataProvider:

selectedIndex=(event.target as ComboBox).selectedIndex;
// Then get the GroupID from the dataProvider
selectedGroupID = groupList[selectedIndex]['GroupID']
Ryan Lynch
public function groupListRH(event:ResultEvent):void{ groupsList=event.result as ArrayCollection;} public function show(event):void{selectedItem=(event.target as ComboBox).selectedIndex;Alert.show(selectedItem.toString().groupId);}<mx:ComboBox dataProvider="{groupsList}" labelField="groupName"id="grpLst"width="150" prompt="Select One Group" change="show(event);" focusIn="init();" /> am not getting like this ...how can i get groupId(exact id which am getting into arraycollection thru remoteobject) of selected GroupName...??
Thirst for Excellence
Append an edit to your question with that code, or create a new question. I'm not a compiler so I can only parse code when it's formatted visually. ;-)
Ryan Lynch