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

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