Batch update problem. IsEdit not properly handled.

Hi there!

Imagine you have a grid with clients and a grid with their orders.

Selecting a client in the client grid, signals the orders grid and it refreshes showing the clients orders.

In the orders grid there is a Boolean (check box) field that the user can select, specifying which orders to send.

This is done with batch update mode.

When hitting the "save" button, the batch update event is triggered, and everything works fine.

But what if you click a different client in the clients grid?

The message that is warning the user for unsaved data is displayed but now the "game is changed" for the grid is refreshed with a new dataset.

For not allowing the grid to refresh I check the 'IsEdit' property of the Grid.

And that works fine when the cell is in edit mode, therefore unsaved data are in place.

But in batch update mode, unsaved data might be there, even when no cell is in edit mode.

Is there something you could advise me to do to avoid the data refresh other than keeping the state of grid on my own?


3 Replies

MS Monisha Saravanan Syncfusion Team May 24, 2022 01:35 PM UTC

Hi Rigakis,


Greetings from Syncfusion support.


We have checked your query and we suspect that you are facing an issue when the orders grid have unsaved changes and clicking an different record at client grid is refreshing the Grid. We suggest you to use OnBatchCancel event. It will trigger when we select an record at client grid with unsaved changes in orders Grid. You will get the changed records detail at the batch cancel event args. By using this you can prevent refreshing the Grid. Otherwise you can use GetBatchChanges method to get the batch changes in the DataGrid. Kindly refer the attached code snippet for your reference.


          

            <SfGrid SelectedRowIndex=2 @ref="Grid" DataSource="@Employees">               

                <GridEvents RowSelected="RowSelecthandler" TValue="EmployeeData"></GridEvents>

            </SfGrid>

 

            <div class='e-statustext'>Showing orders of Customer: <b>@SelectedCustomer</b></div>

            <SfGrid DataSource="@GridData" @ref="Grid1" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })"  Query="@(new Query().Where("EmployeeID", "equal", RowIndex))">

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

           <GridEvents OnBatchCancel="OnBatchCancel"  OnActionComplete="ActionComplete" OnBatchSave="BatchSaveHandler" TValue="Order"></GridEvents>

                <GridColumns>

            </SfGrid>

        </div>

    </div>

</div>

@code{

 

    public void OnBatchCancel(BeforeBatchCancelArgs<Order> args)

{

 

}

 

 

 


Reference: https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Grids.SfGrid-1.html#Syncfusion_Blazor_Grids_SfGrid_1_GetBatchChangesAsync


Kindly get back to us if you have further queries.


Regards,

Monisha



RI Rigakis May 27, 2022 10:47 PM UTC

Thanx a lot!!!

OnBatchCancel did not work because the grid is getting the notification for refreshing before the event is getting hit.
Checking though the GetBatchChanges ​returned structure, solved my problem. 




MS Monisha Saravanan Syncfusion Team May 30, 2022 06:23 AM UTC

Hi Rigakis,


Thanks for the Update.


We are glad to hear that the reported issue has been resolved. So we are proceeding to mark this ticket as closed. So kindly get back to us if you have further queries.


Regards,

Monisha


Loader.
Up arrow icon