Apache – DataGrid selectedItem binding with selectedItem in Combox

apache-flex

In Flex, how can I set the selectedItem of a ComboBox to the selectedItem of a grid (name,mobile,category)? If I select one row in the grid(category), that selected item (category item) must be selected item in categories ComboBox.

<mx:DataGrid id="dg" width="425" height="328" rowCount="5" 
  dataProvider="{contactList}" cornerRadius="3" 
  change="selectedItem=(event.target as DataGrid).selectedItem.groupId;">  
<mx:ComboBox id="grpName" dataProvider="{groupsList}" labelField="groupName"
  selectedIndex="{selectedItem}" />

Best Answer

If the data provider of the ComboBox and the DataGrid are similar (of same length and contents) you can bind the selectedIndex property to achieve this.

<mx:ComboBox selectedIndex="{dg.selectedIndex}"/>
Related Topic