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

147
Views
Tabulator add a new row and edit content

I have following Tabulator setup:

var table = new Tabulator("#data-table", {
            layout: "fitColumns", //fit columns to width of table
            columns: [ //Define Table Columns
                { title: "Name", field: "name", editor:"input" },
                { title: "IP", field: "ip" },
            ],
            index:"name"
        });

Also, I register a function to insert a new row:

function insertRow(){
            table.addData([{
                name: "",
                ip: "",
            }], true).then(function(rows){
                if (rows.length == 0) return;
                rows[0].getCell("name").edit();
            })

        }

When I call the function insertRow(), it can insert a new row into the table but not open editing for the first cell.
However, following code works:

if (rows.length == 0) return;
                setTimeout(function(){
                    rows[0].getCell("name").edit();
                }, 100);

In the documentation http://tabulator.info/docs/4.9/update,

The addData method returns a promise, this can be used to run any other commands that have to be run after the data has been loaded into the table. By running them in the promise you ensure they are only run after the table has loaded the data.

So, it seem that we cannot call rows[0].getCell("name").edit() immediately inside the promise.
Is this correct?
Is there any problem with my code?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you are only adding one row, use the addRow function instead of the addData function:

table.addRow({name: "", ip: ""], true)
.then(function(row){
   rows.getCell("name").edit();
});
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!