We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Disable CommandButton by Parameter

Thread ID:





144249 Apr 26,2019 01:51 PM UTC Apr 29,2019 09:16 AM UTC Angular - EJ 2 1
Tags: Grid
Julio Cezar Mendonca
Asked On April 26, 2019 01:51 PM UTC

Good Morning,

I need to know how to disable and enable a 'CommandButton' in GRID.

Here is the code snippet below:

    // grid commands
     this.commands = [
       {title: 'Delete', buttonOption: {content: '<i class = "fas fa-trash-alt"> </ i>', cssClass: 'e-flat e-danger', click: this.onDelete.bind (this)}},
       {title: 'Edit', buttonOption: {content: '<i class = "fas fa-pencil-alt"> </ i>', cssClass: 'e-flat e-success', click: this.onEdit.bind (this)}},
       {title: 'Add', buttonOption: {content: '<i class = "fas fa-plus"> </ i>', cssClass: 'e-flat e-info', click: this.onAddChildren.bind (this (I.e.

I would need the Add button to be disabled, or invisible, when a parameter is true.

Could I do this?

Thavasianand Sankaranarayanan [Syncfusion]
Replied On April 29, 2019 09:16 AM UTC

Hi Julio, 

Greetings from Syncfusion support 

We have validated your requirement. You can achieve your requirement using queryCellInfo event of the Grid. Please refer the below code snippet to achieve your requirement. Like the below code snippet we can render icons and using QueryCellInfo event we can remove the icon. 


ngOnInit(): void { 
        this.childGrid = { 
            queryCellInfo: function (args) { 
              if(args.column.headerText == 'Commands' && args.data.Freight > 30){   //add your condition 
              args.cell.getElementsByTagName('button')[0].remove();                             //remove the element 
            columns: [ 
                   { headerText: 'Commands', width: 120, commands: [ 
{ buttonOption: {cssClass:'e-flat',iconCss: 'fa fa-pencil', click: this.onClick } },     //add the icons in custom Command 
{ buttonOption: {cssClass:'e-flat',iconCss: 'fa fa-random', click: this.onClick } }] 

We have prepared a  sample based on your requirement. Please refer the below sample and documentation link for more information: 

Please get back to us if you need further assistance. 

Thavasianand S. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon