ag-grid disable checkbox programatically via gridOptions API

Viewed 19403

I have a column with checkboxSelection=true

Under some conditions and via the API, I would like to decide whether the checkbox is readonly, i.e., I can't check/uncheck.

Is this possible?

5 Answers

If someone is still looking for an answer for this, I found a simple solution,

in your gridOptions add the following

gridOptions = {
columnDefs: [
  {
    checkboxSelection: true,
    cellStyle: params => 
      params.value === 'YOUR_VALUE' ?  
          {'pointer-events': 'none'}
          : ''
   }
 ]  
};

As per documentation, you can you isRowSelectable in your gridConfig

    isRowSelectable: function(rowNode) {
        return rowNode.data ? rowNode.data.condition: false;
    },

isRowSelectable does not work in single selection mode. Better to disable it using css

cellClassRules: { 'checkbox-disabled': isCheckboxDisabled , }

Related