DataGrid DropdownList selected Item
Michelle5002 May 4, 2011 2:57 PMWhen I first pull up the datagrid, in the column which contains a dropdownlist of a Value Object from a WebService, it displays the objects field as I wanted. However, when I select the column, instead of showing the drop down list, it just shows a blank drop down box. Then when I click the drop down arrow it does show my list as I like it. But when I select an item and Item selected returns the object, instead of displaying the objects field as it did before I selected the column, it now displays that there is an object called ReasonsDto. So, how do I get the drop down list to not force the second interaction and how do I get the selected item saved to the table as an object but only display the field?
Here is my current code
<mx:DataGridColumn headerText="Reason" width="100" dataField="reason.reason" editable="true"
editorDataField="selectedItem">
<mx:itemEditor>
<fx:Component>
<mx:Canvas>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.events.FlexEvent;
import mx.controls.Alert;
[Bindable]
public var reasonsDP:ArrayCollection;
protected function sdd_creationCompleteHandler(event:FlexEvent):void
{
getReasonsResult.token = personnelBean.getReasons();
}
public function get selectedItem():ReasonDto
{
return selectableDropDown.selectedItem;
}
public function get prompt():ReasonDto
{
return selectableDropDown.selectedItem.reason;
}
<!-- public override function setFocus():void
{
selectableDropDown.setFocus();
}
-->
protected function getReasonsResult_resultHandler(event:ResultEvent):void
{
reasonsDP = getReasonsResult.lastResult;
}
]]>
</fx:Script>
<fx:Declarations>
<personnelbean:PersonnelBean id="personnelBean" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="getReasonsResult" result="getReasonsResult_resultHandler(event)"/>
<valueObjects:ReasonDto id="reasonDto"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<components:SelectableDropDown id="selectableDropDown"
dataProvider="{reasonsDP}"
labelField="reason"
selectField="reason"
selectFieldValue="reason"
creationComplete="sdd_creationCompleteHandler(event)"/>
</mx:Canvas>
</fx:Component>
</mx:itemEditor>
</mx:DataGridColumn>


