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

123
Views
Datatable column filter multiselect with unique value once clicked

I used the following code to populate a table with multiselect filters on each columns and it works just fine : multiselect columns filters table exemple

$(document).ready(function() {
$('#example').DataTable({
initComplete: function() {
  this.api().columns().every(function() {
    var column = this;
    //added class "mymsel"
    var select = $('<select class="mymsel" multiple="multiple"><option value=""></option></select>')
      .appendTo($(column.footer()).empty())
      .on('change', function() {
        var vals = $('option:selected', this).map(function(index, element) {
          return $.fn.dataTable.util.escapeRegex($(element).val());
        }).toArray().join('|');

        column
          .search(vals.length > 0 ? '^(' + vals + ')$' : '', true, false)
          .draw();
      });

    column.data().unique().sort().each(function(d, j) {
      select.append('<option value="' + d + '">' + d + '</option>')
    });
  });
  //select2 init for .mymsel class
  $(".mymsel").select2();
}

}); });

However, when I select a value in a random column filter, the other filters offers the list of all possibles values instead of the distinct ones based on the previous filter.

Is there a way to do this ?

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!