We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Update Table Summary on KeyPress For Newly Added row Using Add new Row Functionality

Following code is added on CurrentCellKeyPress event, Kindly giude me what i am doing wrong ??
private void sfDataGrid_CurrentCellKeyPress(object sender, Syncfusion.WinForms.DataGrid.Events.CurrentCellKeyPressEventArgs e)
{
if (sfDataGridEntry.CurrentCell.Column.MappingName == "dcBillAmt" && sfDataGridEntry.CurrentCell.Column is GridNumericColumn
&& sfDataGridEntry.CurrentCell.CellRenderer.CurrentCellRendererElement != null)
{
int recordIndex = sfDataGridEntry.TableControl.ResolveToRecordIndex(e.RowIndex);
object rowData = null;
if (sfDataGridEntry.IsAddNewRowIndex(e.RowIndex))
{
rowData = sfDataGridEntry.View.CurrentAddItem;
}
else if (sfDataGridEntry.GroupColumnDescriptions.Count > 0)
{
NodeEntry record = sfDataGridEntry.View.TopLevelGroup.DisplayElements[recordIndex];
if (!record.IsRecords)
{
return;
}

rowData = (record as RecordEntry).Data;
}
else
{
RecordEntry record = sfDataGridEntry.View.Records.GetRecord(recordIndex);
rowData = record.Data;
}
if (rowData != null)
{
ItemPropertiesProvider propertyAccessProvider = sfDataGridEntry.View.GetPropertyAccessProvider();
if (decimal.TryParse(sfDataGridEntry.CurrentCell.CellRenderer.CurrentCellRendererElement.Text, out decimal cellValue))
{
//Update the edited value to the record and refresh the summary.
propertyAccessProvider.SetValue(rowData, sfDataGridEntry.CurrentCell.Column.MappingName, cellValue);
sfDataGridEntry.TableControl.Refresh();
}
}
}
}

1 Reply

Adhikesevan Kothandaraman June 25, 2019 01:43 PM UTC

Hi Avinash, 

Thanks for using Syncfusion products. 

The summary value will not update while editing on the AddNewRow. It will be calculated only when the new row is added to the underlying collection which is bounded to the DataSource property.    
If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further. 

Regards, 
Adhi 

Loader.
Live Chat Icon For mobile
Up arrow icon