Toolbar Update item and BatchEditing

Hi 

Working with the Demo Batch Editing and Update and Cancel toolbar items. Is there any way to enable the toolbar items(Update and Cancel) once we start editing a cell? now it gets enabled when you unfocus or go to another cell/


5 Replies

VN Vignesh Natarajan Syncfusion Team August 19, 2021 05:32 AM UTC

Hi Adriana,  
 
Thanks for contacting Syncfusion support.  
 
Query: “Is there any way to enable the toolbar items(Update and Cancel) once we start editing a cell? now it gets enabled when you unfocus or go to another cell/ 
 
We have achieved your requirement using EnableToolbarItemsAsync method and OnCellEdit event of Grid. OnCellEdit event will be triggered when cell goes into edit mode. In that event, we have used EnableToolbarItemsAsync method of Grid to enable Update and cancel button of Grid. 
 
Refer the below code example.  
 
<SfGrid ID="Grid" @ref="GridInstance" DataSource="@Orders" AllowPaging="true" Toolbar="@(new List<string>() { "Add""Delete""Update""Cancel" })" Height="315"> 
    <GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch"></GridEditSettings> 
    <GridEvents OnCellEdit="CellEdit" TValue="Order"></GridEvents> 
. . . .. . 
</SfGrid> 
  
@code{ 
  
    SfGrid<Order> GridInstance { getset; } 
  
    public List<Order> Orders { getset; } 
  
    public async Task CellEdit(CellEditArgs<Order> Args) 
    { 
        //        Grid_update - denotes Grid for Grid ID 
        await GridInstance.EnableToolbarItemsAsync(new List<string>() { "Grid_update""Grid_cancel" }, true); 
    } 
 
 
For your convenience we have attached the sample which can be downloaded from below  
 
 
Refer the below UG documentation for your reference. 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 



AS Adriana Selena Tito Ilasaca August 19, 2021 01:42 PM UTC

Hi thanks for the answer, I meant something like CellValueChange, so the buttons get enabled when you delete the current cell content or start typing, not when the edition mode starts. 
I think is possible with templates but when I want to use the simple column and its EditType.



VN Vignesh Natarajan Syncfusion Team August 20, 2021 08:32 AM UTC

Hi Adriana,  
 
Thanks for the update.  
 
Query: “I think is possible with templates but when I want to use the simple column and its EditType 
 
We have analyzed your query and as mentioned by you, it is not possible to achieve your requirement using default edit type. But we can achieve your requirement while using EditTemplate feature of Grid. So kindly whether it is fine for you achieve your requirement using EditTemplate feature of Grid.  
 
Based on your confirmation, we will prepare and update the solution.  
 
Regards, 
Vignesh Natarajan 



KD Kerry Duggento January 12, 2023 02:37 PM UTC

I have two problems I'd like to point out:  

1. The names of the toolbar items must match the name of the items in   await GridInstance.EnableToolbarItemsAsync(new List<string>() { "Grid_update""Grid_cancel" }, true); 

They should be "Update" and "Cancel" not "Grid_update" and "Grid_cancel".


2. It should probably be mentioned that once you set the toolbar items enabled or disabled they no longer behave normally by disabling when something is saved or enabling when something is edited.  You have now taken complete control of that and there is no way to hand it back to the grid.



SP Sarveswaran Palani Syncfusion Team January 18, 2023 04:38 AM UTC

Hi Kerry,

Greetings from Syncfusion support.

From your query, we would like to inform you that, we’ll set toolbar item name similar to the Grid Id. This will help us to easily identify and track the toolbar item when working with multiple grids in a single project.

Regards,
Sarvesh


Loader.
Up arrow icon