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

199
Visualizações
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 Respostas
Responde à pergunta

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 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