Error in Version 19.2.44 version upon updatecell

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


5 Replies

RN Rahul Narayanasamy Syncfusion Team July 12, 2021 08:44 AM UTC

Hi Tyrone, 

Greetings from Syncfusion. 

We have validated your query and we suspect that you are facing the problem while updating other column values in OnCellSave event of the Grid. We have checked your reported case by preparing a sample based on your requirement we could not able to reproduce the problem. The correct totalcost value is updated correctly and the OnCellSave is not called multiple times. 

Find the below sample for your reference. 


Also, you have called Refresh method of the Grid in OnCellSave event. There is no need to call Refresh method in this method. Could you please remove this Grid.Refresh line and ensure the reported problem at your end? 

If you are still facing the problem then could you please share the below details. It will be helpful to validate and provide a better solution. 

  • Full Grid code snippets.
  • Reproduce the problem in the provided sample.
  • Video demonstration of the problem.
  • Share a simple reproduceable sample if possible.

Regards, 
Rahul 



TY Tyrone July 12, 2021 09:50 AM UTC

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. 

 



RN Rahul Narayanasamy Syncfusion Team July 13, 2021 12:10 PM UTC

Hi Tyrone, 

Thanks for the update. 

Query: is there is a  way to get the current RowIndex? await Grid.GetRowIndexByPrimaryKeyAsync(args.RowData.OrderID); is not applicable to my program 

We have validated your query and we suggest you to get the row index in CellSelecting event arguments instead of using GetRowIndexByPrimaryKeyAsync method. Find the below code snippets for your reference. 

 
<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 
    } 
} 


Reference

Please let us know if you have any concerns. 

Regards, 
Rahul 



TY Tyrone replied to Rahul Narayanasamy July 14, 2021 01:00 AM UTC

That works like charm. Thanks Rahul..



RN Rahul Narayanasamy Syncfusion Team July 14, 2021 03:55 AM UTC

Hi Tyrone, 
 
Thanks for the update. 
 
We are happy to hear that the provided solution was helpful to achieve your requirement. Please get back to us if you need further assistance. 
 
Regards, 
Rahul 


Loader.
Up arrow icon