- Home
- Forum
- Angular - EJ 2
- disable/enable items in toolbar grid when you don't have an id set
disable/enable items in toolbar grid when you don't have an id set
I need to disable some grid buttons but these don't keep the fixed id of the example already exposed by syncfusion:



It was implemented as follows:
but the "Delete" button cannot be disabled because its id is variable:
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
RS
Rajapandiyan Settu
Syncfusion Team
August 31, 2020 01:28 PM UTC
Hi Pablo,
Greetings from Syncfusion support.
Query : I need to disable some grid buttons but these don't keep the fixed id of the example already exposed by syncfusion
We have validated your query at our end. By using Grid element id with the button text value we can Enable/Disable the default built-in toolbar items in the Grid. please use the below code to disable the delete button in the Grid.
|
this.grid.toolbarModule.enableItems(['Click', this.grid.element.id + '_delete'], false); // this.grid.element.id returns grid id.
|
Find the below sample for your reference.
Please get back to us if you need further assistance.
Regards,
Rajapandiyan S
PB
Pablo Barrera
September 1, 2020 01:03 PM UTC
The "add, edit and delete" buttons are disabled with the proposed solution:
but when any filtering option is clicked they are enabled again:

how can you control that?
RS
Rajapandiyan Settu
Syncfusion Team
September 2, 2020 11:33 AM UTC
Hi Pablo,
Thanks for your update.
Query : The "add, edit and delete" buttons are disabled with the proposed solution. but when any filtering option is clicked they are enabled again. how can you control that?
The built-in toolbar items Add, Edit, Delete, Cancel, Update are used to perform CRUD actions in the Grid.
When performing any action in the Grid refreshes the whole Grid, so the toolbar module enables/disables default built-in items (Add, Edit, Delete, Cancel, Update) based on Grid’s edit state. Since this is the behavior of EJ2 Grid.
Based on your query we could see that you need to disable the Add, Edit, Delete button for each grid action. You can achieve this by disabling edit Settings in the Grid, please refer to the below code example and sample for more information.
|
buttonClickdisable(args){
this.grid.editSettings.allowAdding = false; // disables the add button
this.grid.editSettings.allowEditing = false; // disables the Edit button
this.grid.editSettings.allowDeleting = false; // disables the Delete button
this.grid.toolbarModule.enableItems(['Click'], false); // Disable toolbar items.
}
|
Please get back to us if you need further assistance with this.
Regards,
Rajapandiyan S
Marked as answer
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
- Marked answer
-
PB Pablo Barrera
- Aug 28, 2020 01:58 PM UTC
- Sep 2, 2020 11:33 AM UTC