Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda