Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

234
Visualizações
Tabulator: reformat cell on 'cellEdited' event

I am new at using Tabulator.js but I am willing to learn and use it deeply. I was indeed looking for a good tableGenerator library for a main project. So far, it seems to be pretty nice. I am currently using a CND link for version 5.0.7.

Now here is my problem: I try to format cell with a background-color depending on the cell value (the cell name is status and the value can be either true or false). It works at the creation of the table. But it doesn't work if I change the cell value afterwards.

I created a method called statusFormatter:

statusFormatter: (cell) => {

        if (cell.getValue() == true) {
            cell.getElement().style.backgroundColor = "#A6A6DF";
        }

        return cell.getValue();
},

I call this method on the cellEdited event:

mainTable.on("cellEdited", function (cell) {
    clientTabulator.statusFormatter(cell);
});

I suppose there is something wrong with the return in the method. But I don't know what to return when it is the style that I need.

Hope someone can help...

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Change your statusFormatter function as

statusFormatter: function (cell, formatterParams, onRendered) {
  
  let position = cell.getRow().getPosition();

  // switch row even and  odd color
  let backgroundColor = cell.getValue() ? "#A6A6DF" : position % 2 ? "#efefef" : "#fff";
  cell.getElement().style.backgroundColor = backgroundColor;

  return cell.getValue();

}
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda