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

194
Visualizações
Get render value of datatable column instead of data value

I am getting my datatable data from ajax.
My table have name surname and status columns I am getting status from database as 0 or 1 for active and inactive after getting the data I render it with like this

"columns": [
        {
          "data": "name"
        },
        {
          "data": "surname"
        },
         {
          "data": "status",
          "render": function(data, type, row) {
            if (data == '1') {
              return '<div class="badge badge-green">active</div>';
            } else {
              return '<div class="badge badge-red">inactive</div>';
            }
          }
        }
]
        

And after rendering the data I am getting dynamically all the statuses in the table and appened it to select element for extra filteration.

I used initComplete function to get values and append it as follows:

initComplete: function() {
      
        // select status column
        dataTable.column(2).data().unique().sort().each(function(data, j) {
          $('#filterByStatus').append('<option value="' + data + '">' + data + '</option>');
        });
         
      }

The thing is since my actual data are 0s and 1s the function I am using is printing 0 and 1 in the select option not the rendered data which are active and inactive.

How to to get the rendered values of cell? like this

<option value="active">active</option>
<option value="inactive">inactive</option>
about 4 years ago · Juan Pablo Isaza
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