disable and activate button on the grid.

Hello, I try disable button or activate.

Example this line:

headerText: "Accion",
commands: [
{ type: "carrito", buttonOptions: { contentType: "imageonly", prefixIcon: "fa fa-shopping-cart", click: "OnClick" } },],

I don't know if exist a function.
Thanks!!


3 Replies

RR Rajapandi Ravi Syncfusion Team June 28, 2021 11:34 AM UTC

Hi Jose, 

Greetings from syncfusion support 

Based on your query we could see that you like to disable the command button based on some condition. We have prepared a sample based on your requirement through the below way using the queryCellInfo event of the EJ2 grid. Please refer the below Code Example and sample for your reference. 

 
queryCellInfo: function(args) { 
                if ((args.cell.classList.contains("e-unboundcell") && args.data as any).ShipCountry === "Brazil") { 
                    (args.cell.querySelector("button[title='Edit']") as any).ej2_instances[0].disabled = true; 
                    args.cell.querySelector("button[title='Edit']").classList.add("e-disabled"); 
                    (args.cell.querySelector("button[title='Delete']") as any).ej2_instances[0].disabled = true; 
                    args.cell.querySelector("button[title='Delete']").classList.add("e-disabled"); 
                } 
 
            } 




Regards,
Rajapandi R



JA Jose Arturo June 28, 2021 03:49 PM UTC

Hello, thanks for you answer.

I see the example. My idea is this, I have 2 grid, the first grid display the products and 1 button example this:

headerText: "Accion",

commands: [

{ type: "carrito", buttonOptions: { contentType: "imageonly", prefixIcon: "fa fa-shopping-cart", click: "OnClick" } },],


When I click the button, I pass the info another grid (2) and later disable the button from first grid.


The secound grid when receive the info, also can remove the row, if is remove the rows, I want enable the button selected from first grid.

 function OnClick(args) {
console.log(args);
args.cell.querySelector("button[role='button']").classList.add("e-disabled");

I put thism there show me error, "args.cell." not support.


I use the Ej1 or JS1



RR Rajapandi Ravi Syncfusion Team June 29, 2021 10:47 AM UTC

Hi Jose, 

Thanks for the update 

Before we start providing solution on your query, we need some information for our clarification. So please share the below details that would be helpful for us to provide better solution. 

1)     Please confirm whether you are using EJ1 or EJ2 Grid in your application. Please refer the below EJ1 and EJ2 documentation and confirm which one you are using. 


2)     Please share your complete Grid rendering code. 

3)     Please share your exact requirement scenario with detailed description. 

Regards,
Rajapandi R


Loader.
Up arrow icon