user14320491
user14320491

Reputation:

how to make row disabled with ag-grid?

I work with ag-grid and i found how to make a column disabled in the doc (https://www.ag-grid.com/documentation-main/documentation.php) but after reading doc i never find how can i make juste one row disabled.

i have already try editable: params => params.data.active === true. Maybe i didn't read right or that doesn't exist. Is someone here with some soluce track ?

Upvotes: 2

Views: 18522

Answers (2)

jessewolfe
jessewolfe

Reputation: 380

I think ag-grid has single row checkbox disablement available natively: https://www.ag-grid.com/angular-data-grid/row-selection/#example-forcing-checkboxes-as-selected

Upvotes: 1

Shujath
Shujath

Reputation: 1171

TL;DR

There is no option in the library to make a single row disabled(both visually and keyboard event based), the only way we could make a single row disabled is by using a customCellRenderer for both header and subsequent cell checkboxes, this allows full control over the checkbox. Besides this, there are three other ways where you can disable ag-grid checkbox based on value,

1)This is using checkBoxSelection param, it would empty the cell based on the condition.

checkboxSelection = function(params) {

   if (params.data.yourProperty) {
      return true;
   }
   return false;
}
  1. This would only disabled click events and style it accordingly,

cellStyle: params => return params.data.status? {'pointer-events': 'none', opacity: '0.4' } : '';

3)This would disable it completely, as you have control over the input, but you may have to use string literals,

cellRenderer: (params) => {
       if (params.value) {
          return `<input type="checkbox" checked/>`;
       }
       else {
          return `<input type="checkbox" />`;
       }
 }

You could use customCellRenderer(customCellRendererParams for props), headerCellRenderer(headerCellRendererParams for props) which accepts a complete JSX component.

  1. I think this would be the most helpful, it allows you to choose the cellRenderer component based on the row value for that column. Its very well described in the ag-grid documentation.

Upvotes: 6

Related Questions