我的数据网格有 3 列,第三列有 textinput itemEditor。当文本更改并且该文本与任何其他文本匹配时(基本上文本是一个 int)。弹出窗口应显示为重复。这是我编写的代码,实际上无法正常工作,而且我是 flex 新手,所以请不要介意我的代码是否奇怪。
<s:GridItemEditor xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
override public function set data(value:Object):void
{
super.data = value;
col3TextField.text = data.columnThree;
}
/*
override public function set value(newValue:Object):void {
col3TextField.text = newValue as String;
}
*/
override public function get value():Object {
if (parseInt(col3TextField.text) == data.columnThree) {
return data[column.dataField];
}
return col3TextField.text;
}
override public function save():Boolean
{
if (parseInt(col3TextField.text) == data.columnThree) {
Alert.show("Duplicate");
}
}
data[column.dataField] = value;
return true;
}
]]>
</fx:Script>
<s:TextInput id="col3TextField" width="100%" color="red" restrict="0-9" maxChars="4"/>
</s:GridItemEditor>
<s:DataGrid x="139" y="340" width="300" height="300" dataProvider="{dgData}" editable="true"
>
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="columnOne" headerText="Data Col #1" editable="false"/>
<s:GridColumn dataField="columnTwo" headerText="Data Col #2" editable="false"/>
<s:GridColumn dataField="columnThree" headerText="Data Col #3" itemEditor="custom.CustomItemEditor" >
</s:GridColumn>
</s:ArrayList>
</s:columns>
</s:DataGrid>