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

119
Visualizações
Tabulator: autoColumnsDefinitions using custom cell formatter and dynamically defined fields?

I have an ajax Tabulator in which I'd like to use a custom cell formatter on columns which are dynamically (but similarly) defined.

Let's say I have a dataset of People with "Event" columns, where the ajax response can contain up to 50 Event fields, named Event1,Event2...Event50. I could manually repeat the definitions using the Column Definition Array or Field Name Lookup Object approaches, like:

    autoColumnsDefinitions:{
        PersonID: { title:"ID #", align:"right"},
        Event1: {formatter: eventFormatter},
        Event2: {formatter: eventFormatter},
        ...[variable # of Event cols here]...
    },

...

   function eventFormatter(cell){
      // format event here
   }

However, using a callback seems more appropriate. When I try something like this, my eventFormatter is never invoked, and no errors or warnings are raised.

    autoColumnsDefinitions:function(definitions){
        definitions.forEach((column) => {
            if(column.field.match(/Event/)) {
                column = {
                    formatter:eventFormatter
                }
            }

Is it possible to apply a custom cell formatter to fields that are not explicitly named prior to data loading?

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

0

Your must update 'column' with formatter as

autoColumnsDefinitions: function (definitions) {
  return definitions.map((column) => {
    if (column.field.match(/(name|title)/)) {
      column.formatter = titleFormatter;
    }
    return column;
  });
}

See JSFiddle

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