I have an ItemEditor with a ComboxBox. To improve user experience, I would like to exit the ItemEditor each time the user select a value in the combobox. So he doesn't have to click outside the cell to validate his choice.
I did this, but it is not working. Why ?
private function comboChange(event:IndexChangeEvent):void
{
var dgOrder:DataGrid = owner as DataGrid;
var dgEvent:GridEvent = new GridEvent(GridEvent.GRID_CLICK);
dgEvent.preventDefault();
dgOrder.dispatchEvent(dgEvent);
}
]]>
</fx:Script>
<s:ComboBox id="ddlCurrency" width="100%" dataProvider="{lstCurrencies}" labelField="CurrencyCode"
prompt="Select a currency" change="comboChange(event)"></s:ComboBox>
EDIT after Marcx comment :
override public function get value():Object {
trace("get value");
ddlCurrency.selectedIndex = newCountryID;
if (ddlCurrency.selectedIndex == -1 || ddlCurrency.selectedItem.CurrencyID == -1){
updateCurrency(data.OrderID, -1);
return "";
} else if ((lstCurrencies[ddlCurrency.selectedIndex as int] as Object).CurrencyCode.toString() != ddlCurrency.selectedItem.CurrencyCode){
return oldValue;
} else {
updateCurrency(data.OrderID, ddlCurrency.selectedItem.CurrencyID);
return ddlCurrency.selectedItem.CurrencyCode;
}
}
private function comboChange(event:IndexChangeEvent):void
{
var dgOrder:DataGrid = owner as DataGrid;
newCountryID = ddlCurrency.selectedIndex;
dgOrder.setFocus();
}
When I select a value on the dropdownList (it was a combobox before), combochange is called and the ddlCurrency.selectedIndex is the one I have just selected, and once the get value() function is called the same ddlCurrency.selectedIndex is the previous index. It why I save the new Index in a variable to force the new index in get value().
I hope I made my self clear.
Thanks in advance. Antoine.
You can try setting the focus on the parent element or directly the application...
From the as3docs: