Hi im new to handsontable. can you guide me on how to make an specific cell readonly when the criteria of another cell is met?
on the image provided if the column cell “status” is active the cell under the “last inactive date” should be readonly
Make ReadOnly specific cells
Hi @jojober
You can do this by the use of some hooks.
For instance, you can react on beforeChange
hook, when the content of cell changed. The crucial in this approach is to use afterInit
to check about the dependencies of some cells.
Here is a link to demo - https://jsfiddle.net/0bnf9u5e/
If the checkbox is unchecked every cell in some row is read-only. Additionally, we add class to them.
Based on this example you could achieve your goal.
I found the solution.
i have done it using:
hot3.updateSettings({
cells: function (row, col) {
var cellProperties = {};
var curData = hot3.getData()[row][7]; //column 7 is the field "status"
if (col == 11 || col==12) { //column needs to be read only
if ((hot3.getData()[row][7]).trim() === 'Active') { //if status is Active
cellProperties.readOnly = true; //make the current cell read only
}
}
return cellProperties;
}
});
hot3.render();
}
Thank you for sending over some feedback. Appreciated.
Feel free to create a new topic when needed.