Monday, May 10, 2010

Datagrid cell validation in Action script

T datagrid with property editable=”true”

public var EditingRowIndex:int;private function testItemEditEnd(event:AdvancedDataGridEvent):void
{
EditingcolIndex=event.columnIndex;
//Previous column index
ComparecolIndex=event.columnIndex -1;
EditingRowIndex=event.rowIndex;
colReference=genricDG.columns[EditingcolIndex];
//Gives column name for Comapre Column
comReference=genricDG.columns[ComparecolIndex]["dataField"];
var CompareValue:int=genricDG.dataProvider[EditingRowIndex][comReference];
var EditedValue:int = parseInt(TextInput(event.currentTarget.itemEditorInstance).text);
if(CompareValue > EditedValue)
{

//no validation coz satisfies the condition
//total.text =String(parseInt(total.text) + EditedValue);

}

else
{

//PREVENT DEFAUL WILL PERSIST VALUE OF DATAGRID CELL
event.preventDefault();
//VALIDATION AFTER CONVERTIN itemEditorInstance INTO TextIput
TextInput(event.currentTarget.itemEditorInstance).errorString =
“Value Must be Less than or qual o” + comReference;

}

}

No comments:

Post a Comment