Get id toolbar item

Hi, I want to get id of built-in toolbar item (add, edit, delete, ...) to enable or disable toolbar item. Can you help me?


1 Reply

JC Joseph Christ Nithin Issack Syncfusion Team November 11, 2021 12:27 PM UTC

Hi Toan,  Greetings from Syncfusion support.  Based on your query, you want to enable and disable the built-in toolbar items of the EJ2 grid. Your requirement can be achieved using the `enableToolbarItems` method of the EJ2 grid.  Please refer the below code example. 
this.gridInstance.enableToolbarItems( 
      [this.gridInstance.element.id + '_excelexport'], 
      false 
    ); 
Note: Since we automatically enable and disable the toolbar items used for CRUD operations, you cannot enable and disable those items using the above method, instead you can enable and disable the feature using the respective properties.Please refer the below code example. 
    this.gridInstance.editSettings.allowEditing = false; 
    this.gridInstance.editSettings.allowDeleting = false; 
In the below sample we have enabled and disabled the 'Edit', 'Delete' and the 'ExcelExport' buttons of the toolbar, when a row in the grid is selected and deselected, respectively. Samplehttps://stackblitz.com/edit/angular-rr2gcw?file=app.component.ts 
Please find the attached sample and revert for more queries.Regards,Joseph I. 


Loader.
Up arrow icon