尝试验证数据网格中的输入,我正在使用函数(取自Adobe示例)。Adobe Flex:尝试验证数据网格输入时出现错误#1034
这是电网如何去:
<mx:DataGrid id="CashGrid" dataProvider="{cash}" editable="true" itemEditBeginning="allowForEdit(event)" itemEditEnd="formatData(event);" sortableColumns="false">
<mx:columns>
<mx:DataGridColumn textAlign="left" dataField="curName" headerText="Currency" />
<mx:DataGridColumn textAlign="right" dataField="value" headerText="Value" width="150">
</mx:columns>
</mx:DataGrid>
这里是从AS部分功能
public function formatData(event:DataGridEvent):void
{
if (event.reason == DataGridEventReason.CANCELLED)
{
// Do not update cell.
return;
}
var newData:String= TextInput(event.currentTarget.itemEditorInstance).text;
// Determine if the new value is an empty String.
if(newData == "")
{
event.preventDefault();
TextInput(cashGrid.itemEditorInstance).errorString=
"Enter a valid string.";
return;
}
}
虽然它工作在源举例来说,在我的例子,在编辑说,网格,一个错误弹出说
TypeError: Error #1034: Type Coercion failed: cannot convert mx.controls::[email protected] to spark.components.TextInput.
试图
import mx.controls.TextInput;
告诉我
Can not resolve a multiname reference unambiguously. spark.components.TextInput.
我想有一些混淆的命名空间,但我不知道如何使这项工作。
帮助!
谢谢
嗨Sankaranarayanan,对不起,我想我搞砸了评论部分莫名其妙。 allowForEdit(event)是一个独立的函数,用于检查某个特定的标志,如果它是真的,则会阻止编辑。它自行工作正常(当formatData(event)不存在时)。此外,即使我从datagrid定义中删除itemEditBeginning =“...”,我也会得到我的错误,所以alowForEdit()不应该是问题的原因。如果您认为它可能有帮助,我仍然可以添加它。谢谢! – user1065079