Problem with SfGrid in EditMode Batch on triggerng OnCellSave and CellSaved - Blazor

I'm having an issue with the SfGrid in Batch mode.


When the event "OnCellSave" is triggered, two things can happen:

- if there's only one row (the same I'm editing), if I insert a metal and then I don't press Enter or Tab, but I just click on another field, I get errors.

- if I'm inserting a second row, when I select a metal, whatever I do, when "OnCellSaved" is triggered, I get errors and the grid crashes.


This makes impossible to use the event, but this event is also the only reason why I'm using the batch mode.


The grid is a bit complex, because it's on three levels, but the problem has nothing to do with this.

I tried to change the code in many ways and by doing it I found out that the problem is triggering the event "OnCellSave".

Indeed if I don't call the event, the issue doesn't persist.

I also tried to use "CellSaved" insted of "OnCellSave" as an event, but the result doesn't change.

I found an existing issue in the forum at this link:

https://www.syncfusion.com/forums/161574/event-is-already-tracked-exception-thrown-when-cellsaved-is-triggered-in-webassembly


It looks similar to my problem, and the related bug results solved:

https://www.syncfusion.com/feedback/21469/exception-error-when-trying-to-edit-a-cell-in-cellsaved-event


I'm using version 19, so it should be fixed, but I still have this issue.

I'm attaching a zip folder with the screenshots of what I described (+ the expected behaviour) and the file with the grid and the event. The problematic grid is the one on the first level (not nested). Code as follows:

<SfGrid @ref="Grid" AllowPaging="true" DataSource="@TemporaryItemsData" Toolbar="@(new List<string>() { "Add","Delete","Update","Cancel" })">

                <GridEvents CellSelected="CellSelectHandler" OnBatchAdd="BatchAddHandler" OnBatchSave="BatchSaveHandler" OnBatchDelete="BatchDeleteHandler" TValue="GroupedItemsDTO"></GridEvents>

                <GridEditSettings AllowAdding="@IsEditingGroupedItemsAllowed" AllowEditing="@IsEditingGroupedItemsAllowed" AllowDeleting="@IsEditingGroupedItemsAllowed" Mode="@EditMode.Batch" ShowConfirmDialog="false"></GridEditSettings>

                <GridSelectionSettings Mode=Syncfusion.Blazor.Grids.SelectionMode.Both></GridSelectionSettings>

                <GridColumns>

                    <!-- Primary Key - Editing feature requires a primary key column for CRUD operations.-->

                    <GridColumn Field=@nameof(GroupedItemsDTO.Id) IsPrimaryKey="true" Visible="false" TextAlign="@TextAlign.Left" Width="140"></GridColumn>


                    <!-- Metallo -->

                    <GridColumn Field=Metal.Name Index="0" HeaderText="@Loc["Oncia_Items_Metal"]" Width="110" EditType="EditType.DropDownEdit">

                        <EditTemplate Context="context">

                            <SfDropDownList ID="Metal___Name" CssClass="e-custom-select" TItem="MetalDTO" TValue="string"

                                            @bind-Value="@((context as GroupedItemsDTO).Metal.Name)" Placeholder="@Loc["Oncia_Items_Metal"]" DataSource="@MetalList">

                                <DropDownListEvents ValueChange="MetalOnChange" TItem="MetalDTO" TValue="string"></DropDownListEvents>

                                <DropDownListFieldSettings Text="Name" Value="Name"></DropDownListFieldSettings>

                            </SfDropDownList>

                        </EditTemplate>

                    </GridColumn>

Here the function called by the event:

 protected async Task CellSavedHandler(CellSaveArgs<GroupedItemsDTO> args)

    {

        if (args.ColumnName == "Metal.Name")

        {

            await GetExchangeRatePercentageList(args.Data.Metal.Name);

            args.Data.ExchangeRatePercentage.DeltaValue = 0;

            args.Data.Total = 0;

        }

        if (args.ColumnName == "GrossWeight" || args.ColumnName == "TareWeight")

        {

            if (args.Data.GrossWeight != null && args.Data.TareWeight != null && (args.Data.GrossWeight - args.Data.TareWeight > 0))

                args.Data.NetWeight = args.Data.GrossWeight - args.Data.TareWeight;

            if (args.Data.ExchangeRatePercentage != null && args.Data.ExchangeRatePercentage.DeltaValue != 0 && args.Data.NetWeight != null)

                args.Data.Total = Decimal.ToDouble(args.Data.ExchangeRatePercentage.DeltaValue) * args.Data.NetWeight;

        }

        if (args.ColumnName == "ExchangeRatePercentage.DeltaValue")

            if (args.Data.NetWeight != null)

                args.Data.Total = Decimal.ToDouble(args.Data.ExchangeRatePercentage.DeltaValue) * args.Data.NetWeight;

    }


Attachment: Syncfusion_7974744f.zip

2 Replies

RN Rahul Narayanasamy Syncfusion Team September 17, 2021 03:50 AM UTC

Hi Welol, 

Greetings from Syncfusion. 

Query: Problem with SfGrid in EditMode Batch on triggerng OnCellSave and CellSaved  ---- I found an existing issue in the forum at this link: https://www.syncfusion.com/forums/161574/event-is-already-tracked-exception-thrown-when-cellsaved-is-triggered-in-webassembly It looks similar to my problem, and the related bug results solved: https://www.syncfusion.com/feedback/21469/exception-error-when-trying-to-edit-a-cell-in-cellsaved-event I'm using version 19, so it should be fixed, but I still have this issue. 

We have validated your query and we would let you know that the reported problem(Exception error when trying to edit a cell in CellSaved event) in this forum was not fixed at our end. You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.  


The above issue will be considered to be included in our upcoming patch release which is expected to be rolled out by end of October, 2021. We will let you know once the fix is included and rolled out successfully. Could you please ensure the reported problem after fixing the reported problem? 

Also we have checked your problem by preparing the sample based on your shared codes. We could able to reproduce the mentioned case at our end. The reported problem exception was not thrown while adding the row and while binding the CellSaved event and  OnCellSave event. Find the below sample for your reference. 


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. 

  • Reproduce the problem in the provided sample and revert back to us.
  • Share a simple reproduceable sample if possible.
  • Video demonstration of the problem.

Please let us know if you have any concerns. 

Regards, 
Rahul 
 



RN Rahul Narayanasamy Syncfusion Team November 9, 2021 03:41 AM UTC

Hi Welol, 

Thanks for your patience. 

We have checked the reported problem “Exception error when trying to edit a cell in CellSaved event” further at our end. It’s a Blazor framework issue and it is resolved in .Net 6.0. So could you please ensure the reported problem “Exception error when trying to edit a cell in CellSaved event” after upgrading your .Net 6.0 version at your end? 

Please let us know if you have any concerns. 

Regards, 
Rahul 
 


Loader.
Up arrow icon