我在数据网格中有一个组合框,从远程对象读取其值。
我想显示提示或设置默认值,因为如果我打开组合框并且我没有选择任何东西我会崩溃。
这是代码:
<mx:DataGridColumn dataField="teacher" width="170" editable="true" editorDataField="selectedItem" >
<mx:itemEditor>
<fx:Component>
<mx:ComboBox dataProvider="{this.outerDocument.staffnames}" >
</mx:ComboBox>
</fx:Component>
</mx:itemEditor>
</mx:DataGridColumn>
远程对象:
[Bindable] public var staffnames:Array = new Array();
public function getAllStaff_resultHandler(event:ResultEvent):void
{
tutortable.dataProvider=getAllStaff.lastResult;
staffnames = new Array();
for each (var i:Staff in getAllStaff.lastResult)
{
staffnames.push(i.name);
staff.push(i);
}
}
错误:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.controls::DataGrid/itemEditorItemEditEndHandler()[E:\dev\hero_private\frameworks\projects\mx\src\mx\controls\DataGrid.as:5321]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\hero_private\frameworks\projects\framework\src\mx\core\UIComponent.as:13128]
at mx.controls::DataGrid/endEdit()[E:\dev\hero_private\frameworks\projects\mx\src\mx\controls\DataGrid.as:4522]
at mx.controls::DataGrid/editorMouseDownHandler()[E:\dev\hero_private\frameworks\projects\mx\src\mx\controls\DataGrid.as:5083]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\hero_private\frameworks\projects\framework\src\mx\core\UIComponent.as:13128]
at mx.managers::SystemManager/mouseEventHandler()[E:\dev\hero_private\frameworks\projects\framework\src\mx\managers\SystemManager.as:2924]