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