How to change the background of all rows in a column after the user changes the content of a cell?

Tags: #<Tag:0x00007fce7550e3a8> #<Tag:0x00007fce7550e268>

I am triggering a function on a given change of a cell. This function searches for information in the database, and depending on the return, I need to change the background color of all cells in a given column. None of my attempts worked.

Hi @jonatas.locateli

Thank you for contacting us. Can you please share your current implementation in a form of a code demo in chosen sandbox?

Hi, @adrian.szymanski,

This function is invoked in the method “afterChange”:

async function calculateWeeks(){

var weekTable = await retWeeks('');
var weeksCapProg = await searchCapProg();

for(var i=0;i<weekTable.length;i++){
	var week = weekTable[i];
	var hours = weeksCapProg.filter(op=>op.CODWEEK==week);
	var column = i+22;
	var rows =;
	if(hours .length>0){
	   for(var k = 0; k < rows; k++){
            /* Here is the function to change the background color of a cell */, column, 'className', 'bgRed');



This is CSS style of the class:

.handsontable .bgRed{
background: #CD5C5C;

Hi @jonatas.locateli

I am not able to reproduce the issue with the code you provided. Please, modify this example so it will be replicable:

@adrian.szymanski, I won’t be able to reproduce all the code as the volume of data is large and comes from an external source. But what would be the correct method or the best way to change the background of all rows in a column?

@jonatas.locateli I understand. So, generally speaking we usually recommend using setCellMeta in a loop to do this. I would recommend to use beforeChange hook in this case instead.

Here’s an example of such implementation:

Thankyou, @adrian.szymanski.

I changed the method to the “before Change”, but it’s still not working. I tried to change a single row and column, as in the example below, and it still didn’t work. = new Handsontable(container, {
data: dados,
columns: colunas,
beforeChange: async (changes) => {
changes.forEach(async (change) => {
const [row, column, oldValue, newValue] = change;, 4, 'className', 'red');;
  	  },       .....

Hi @jonatas.locateli

Do you get any errors in the dev console, or it’s just not doing anything?

Hi, @adrian.szymanski

No erros in the dev console, it’s just not doing anything.

Hi @jonatas.locateli

I won’t be able to suggest anything else without seeing your actual implementation. The issue must lie somewhere else, as the solution I showed you is pretty straightforward, and should work anywhere.