My datagrid has 3 columns and the third column is having the textinput itemEditor. when the text changes and if that text matches with any other text(basically the text is an int). the popUp should appear as duplicate. here is the code what i wrote which actually not working properly and I'm new to the flex, so please don't mind if my code is weird.
<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>