Hi,
I'm using following method to save data after editing cell in SfDataGrid:
public void CurrentCellEndEdit(CurrentCellEndEditEventArgs e)
{
if (e.OriginalSender is SfDataGrid grid && !grid.IsFilterRowIndex(e.RowColumnIndex.RowIndex))
{
var data = grid.View.GetRecordAt(grid.ResolveToRecordIndex(e.RowColumnIndex.RowIndex))?.Data;
// save data
}
}
It works until grouping is used. Then I'm getting wrong record in data variable. Other I was editing.
Seems that record index is wrong. Isn't that a bug?
|
private void OnCurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs e)
{
if (e.OriginalSender is SfDataGrid grid && !grid.IsFilterRowIndex(e.RowColumnIndex.RowIndex))
{
object data = null;
//get the record index
var recordIndex = grid.ResolveToRecordIndex(e.RowColumnIndex.RowIndex);
//Here check the Grouping applied or not in SfDataGrid
if (grid.View.TopLevelGroup != null)
{
// Get the edited record while grouping applied in SfDataGrid
var record = grid.View.TopLevelGroup.DisplayElements[recordIndex];
if (!record.IsRecords) //skips caption summary, group summary rows
return;
//get the record
data = (record as RecordEntry).Data;
}
else
{
// Get the edited record while grouping not applied in SfDataGrid
data = grid.View.GetRecordAt(recordIndex)?.Data;
}
// save data
}
} |
OK, thanks,