How to use set rowcellvalue and get rowcellvalue

I have an grid with batch mode.

I would like to know how to use SetRowCellValue and GetRowCellValue function when I leave from cell.

For example

I have three column in grid

Quantity : 1000
Price : 3
Total Amount : 3000

When I leave from price column,then it should get value from quantity and price and then value should set in Amount column.

1 Reply 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team April 13, 2021 07:05 AM UTC

Hi Ismail, 

Greetings from Syncfusion support. 

We have validated your query and based on your scenario we have prepared a sample. We have used the OnCellSaved event and the UpdateCell method to achieve your scenario. 

<SfGrid @ref="Grid" DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })" Height="315"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings> 
    <GridEvents CellSaved="CellSavedHandler" TValue="Order"></GridEvents> 
.. 
.. 
</SfGrid> 
 
@code{ 
 
    public async Task CellSavedHandler(CellSaveArgs<Order> args) 
    { 
        if (args.ColumnName == "Price") 
        { 
            var total = (double)args.Value * args.RowData.Quantity; 
            var index = await Grid.GetRowIndexByPrimaryKey(args.RowData.OrderID); 
            await Grid.UpdateCell(index, "TotalAmount", total); 
        } 
    } 
} 



Documentation  


Regards, 
Jeevakanth SP. 


Marked as answer
Loader.
Up arrow icon