How to get the cell value through OnCellEdit event of SfGrid?

Answer:

The cell value can be retrieved using the data and column name of the CellEdit event arguments. Here is the code snippet for your reference,

<SfGrid DataSource="@Orders">

<GridEvents OnCellEdit="CellEditHandler" TValue="Order">GridEvents>

<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch">GridEditSettings>

<GridSelectionSettings Mode=SelectionMode.Cell>GridSelectionSettings>

<GridColumns>

. . .

GridColumns>

SfGrid>

@code{

. . .

public void CellEditHandler(CellEditArgs args)

{

// Here you can customize your code

var cellvalue = args.Data.GetType().GetProperty(args.ColumnName).GetValue(args.Data, null); //get cell value here.

}

}

Find the sample for getting the cell value through OnCellEdit event from here.


Loader.
Up arrow icon