How to block a single cell for editing without block the column

244 views Asked by At

I have a table with 3 columns: [location] [dateStart] [dateEnd] I want the user select a location and after that select dateStart and dateEnd. For that I want disable the cells of dateStart and dateEnd.

onCellValueChanged: (params) => {
      if (this.locationIsMandatory) {
            if (params.newValue) {
                  params.columnApi.getColumn('dateStart').getColDef().editable = true;
                  params.columnApi.getColumn('dateEnd').getColDef().editable = true;
      }
}

This code blocks the columns but in all the rows of the table and I just want it in the row what the user is modifying.

Regards :)

1

There are 1 answers

0
Ghonima On BEST ANSWER

Set the editable column definition into a function which returns true or false based on your need.

editable: function(params) {
    if (condition) {
        return true;
    }
    return false;
}

Note: you can get the row data and column data from params