private void Datagrid_CurrentCellValidated(object sender, CurrentCellValidatedEventArgs e)
{
var dataGrid = e.OriginalSender as SfDataGrid;
var record = (e.RowData) as OrderInfo;
var total = record.OrderID + record.Amount;
if (total == 0 && this.datagrid.View.CurrentEditItem!= null && !datagrid.View.IsAddingNew)
{
//cancel the EndEdit while sum of two properties is zero
this.datagrid.View.CancelEdit();
//disable the editing mode in SfdataGrid while sum of two properties is zero
this.datagrid.AllowEditing = false;
}
else if (datagrid.View.IsAddingNew)
{
var addNewRecord = this.datagrid.GetRecordAtRowIndex(this.datagrid.SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex) as OrderInfo;
var addNewRowTotal = addNewRecord.OrderID + addNewRecord.Amount;
if (addNewRowTotal == 0)
{
//cancel the EndEdit while sum of two properties is zero for AddNewRowControl
datagrid.GetAddNewRowController().CancelAddNew();
//disable the editing mode in SfdataGrid while sum of two properties is zero for AddNewControl
this.datagrid.AllowEditing = false;
}
}
} |