How to use OnBatchSave and OnToolbarClick handler same time.

I am trying to use the OnBatchSave and OnToolbarClick handler same time. But, it does not allow me.

If I will use OnToolbarClick, the OnBatchSave event is called but the change is not recorded.

If I remove the OnToolbarClick, the OnBatchSave event works but I can't be using the feature like export to excel.

<GridEvents OnBatchSave="BatchSaveEventHandler" OnBatchDelete="BatchDeleteEventHandler" OnToolbarClick="ToolbarClickHandler" TValue="DismantledCarPartDisplayModel"></GridEvents>

Is there any solution for this?


Thank you.


1 Reply

RN Rahul Narayanasamy Syncfusion Team July 15, 2021 03:43 AM UTC

Hi Bibek, 

Greetings from Syncfusion. 

Query: If I will use OnToolbarClick, the OnBatchSave event is called but the change is not recorded. If I remove the OnToolbarClick, the OnBatchSave event works but I can't be using the feature like export to excel. 

We have validated your query and you are facing the problem while using OnToolbarClick and OnBatchSave events. We have checked the reported problem and we could not face the reported problem. The OnToolbarClick and OnBatchSave events are triggered properly. We can able to perform the excel export while using both events and the changes are records in OnBatchSave event arguments. Find the below sample for your reference. 

 
<SfGrid ID="Grid" @ref="DefaultGrid" DataSource="@Orders" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel", "ExcelExport" })" 
        AllowExcelExport="true"> 
    <GridEvents OnToolbarClick="ToolbarClickHandler" OnBatchSave="BatchSaveHandler" TValue="Order"></GridEvents> 
    <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Batch"></GridEditSettings> 
    <GridColumns> 
        . . . 
    </GridColumns> 
</SfGrid> 
 
@code{ 
    private SfGrid<Order> DefaultGrid; 
    . . . 
 
    public void BatchSaveHandler(BeforeBatchSaveArgs<Order> args) 
    { 
        // Here you can customize your code 
        // you can see the changes in args.BatchChanges 
    } 
    public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args) 
    { 
        if (args.Item.Id == "Grid_excelexport") //Id is combination of Grid's ID and itemname 
        { 
            await this.DefaultGrid.ExcelExport(); 
        } 
    } 
} 



Reference


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

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

Regards, 
Rahul 


Loader.
Up arrow icon