Hi team
Just to be informed that
UpdateCell keeps on calling OnCellSave event but does not render the right ColumnName.
public void CellSavedHandler(CellSaveArgs<SODetailEdit> args)
{
if (args.ColumnName == "Quantity")
{
QuantityValue = (double)args.Value;
ComputeDetail();
}
if (args.ColumnName == "UnitCost") // I made changes on Unit cost and goes to ComputeDetail() method.
{
UnitCostValue = (double)args.Value;
ComputeDetail();
}
GridDetail.Refresh();
}
public async Task ComputeDetail()
{
TotalCostValue = QuantityValue * UnitCostValue;
SubWeightValue = QuantityValue * WeightValue;
SubCommissionValue = UnitCostValue * WeightValue;
TotalCommissionValue = QuantityValue * UnitCostValue * WeightValue;
await GridDetail.UpdateCell(RowIndexDetail, "TotalCost", TotalCostValue); // this keeps on calling cellsave but columnname is still sets on UnitCost instead on TotalCost.. Thats why I'm having infinite ComputeDetail() call loop.
await GridDetail.UpdateCell(RowIndexDetail, "SubWeight", SubWeightValue);
await GridDetail.UpdateCell(RowIndexDetail, "SuubCommission", SubCommissionValue);
await GridDetail.UpdateCell(RowIndexDetail, "TotalCommission", TotalCommissionValue);
}
Regards,
Tyrone
Thanks Rahul for the immediate response. Your sample will help me to Isolate the problem.
btw, is there is a way to get the current RowIndex?
await Grid.GetRowIndexByPrimaryKeyAsync(args.RowData.OrderID); is not applicable to my program since my OrderID is autogenerated from EFCore and Im using batch saving. It will not be applicable to added lineitems.
<SfGrid @ref="Grid" DataSource="@Orders" AllowSelection="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })" Height="315">
<GridEvents OnCellSave="CellSaveHandler" CellSelecting="CellSelectingHandler" TValue="Order"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings>
<GridSelectionSettings Mode=SelectionMode.Cell></GridSelectionSettings>
<GridColumns>
. . .
</GridColumns>
</SfGrid>
@code{
SfGrid<Order> Grid;
. ..
public double RowIndexDetail { get; set; }
public async Task CellSaveHandler(CellSaveArgs<Order> args)
{
//RowIndexDetail = await Grid.GetRowIndexByPrimaryKeyAsync(args.RowData.OrderID); //remove this line
if (args.ColumnName == "Quantity")
{
. . .
}
}
. . .
public void CellSelectingHandler(CellSelectingEventArgs<Order> args)
{
RowIndexDetail = args.RowIndex; //get row index here
}
}
|
That works like charm. Thanks Rahul..