Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!