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

201
Views
I have a datatable in Javascript and (almost) everything works fine, but i don't know how to refer to a value in the same row...any ideas?

Basically, I have a button in every row in the third column, and when the user clicks on the button, I would like to call a function with parameters (they are from the table row). I saw that someone use row.errorType (for example), but that's gave me 'undefined' value :( Any ideas?

            columns: [
                {
                    "data": "errorType",
                    "render": function (data) {
                        return data;
                    }
                },
                {
                    "data": "errorDescription",
                    "render": function (data) {
                        return data;
                    }
                },
                {
                    "data": "entityId",
                    "render": function (data, row) {
                        return `<button class="newError" onclick="openModal(${row.errorType}, ${row.errorDescription}, ${data})"><i class="icon ticket errorTableIcon"></i></button>`;
                    }
                }
            ],
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are using the DataTables columns.render option, but you are not supplying the expected parameters.

You are using:

"render": function (data, row) { ... }

You should be using:

"render": function (data, type, row, meta) { ... }

So, what you are referring to as row is actually type. Change your parameters as shown above to pick up the row data object correctly - and then you should be able to use variables such as row.errorType in your string builder.


You still need to ensure that variables which resolve to strings are themselves enclosed in quotes, so your string template may need to be adjusted.

For example, you may need "${row.errorDescription}" instead of ${row.errorDescription}.

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!