How to change editSettings.allowDeleting after creation

I'm trying to modify various grid settings based on other events on the form, such as changing data source, column visibility, etc. The one that has me stumped is changing the edit settings. I've tried this:

      var grid = $("#GridContainer").data("ejGrid");
      grid.model.editSettings.allowDeleting == false;
      grid.model.toolbarSettings.toolbarItems = ["add", "edit", "update", "cancel", "responsiveSorting"];

but the toolbar delete button doesn't go away. Any suggestions? Thanks in advance!

brian

1 Reply

VN Vignesh Natarajan Syncfusion Team November 13, 2017 02:01 PM UTC

Hi Brian, 

Thanks for using Syncfusion Products. 

We have analyzed your query and we suspect that you want to modify the toolbar items and disable the deleting on some event. We have achieved your requirement by passing the toolbarItmes through setmodel.  

Refer the below code snippet 

actionComplete: function(args){ 
              if(args.requestType == "sorting") 
                $("#Grid").ejGrid({ 
                  editSettings: {allowDeleting: false },  
                  toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] } }); 
              
              }, 

Note: here we have passed editSettings and toolbarSettings to grid via setmodl and updated the grid. We have done the changes when the any one of the column in sorted.  

Refer the below screenshot 

 

While initial rendering the toolbar items. 

 

After sorting a column. 


For your convenience we have prepared a JSplayground sample  


Regards, 
Vignesh Natarajan 



Loader.
Up arrow icon