Intecept Add and Delete

I was wonder if it would be possible to intercept the add and delete button clicks of the toolbar on the grid? I have custom code that needs to run to add and delete items from the database. Thanks!

1 Reply

VN Vignesh Natarajan Syncfusion Team July 2, 2018 12:15 PM UTC

Hi Mathew, 

Thanks for using Syncfusion products. 

According to your query you need to perform some action when toolbar items are clicked. We suggest you to achieve your requirement using ToolbarClick event of the Grid. 

Refer the below code snippet 

@(Html.EJ().Grid<object>("FlatGrid") 
                           .Datasource(ds => ds.URL("/Home/UrlDataSource").Adaptor(AdaptorType.UrlAdaptor)) 
                            
                           .ClientSideEvents(evt => evt.ToolbarClick("OnToolbarClick")) 
                
                                …...                            
 
                          .Columns(col => 
                                   { 
                                                  col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); 
                                                   
                              …... 
                                    })) 
 
 
<script type="text/javascript"> 
    function OnToolbarClick(args) { 
 
       if (sender.itemName == "Add")    // itemName will Add when add button is clicked 
        {     
            // perform your action here 
        } 
    } 
</script> 


Refer our API documentation for your reference 

  
Regards, 
Vignesh Natarajan 



Loader.
Up arrow icon