• Jobs
  • About Us
  • Jobs
    • Home
    • Jobs
    • Courses and challenges
  • Businesses
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

710
Views
How to redraw Datatable columns filter?

I am using datatable plugin with individual column filters, I found this is a great plugin but it's only filtering table data not the values in columns filter dropdown after selection of the column filter.

Here I am looking, when I select one column filter then it will also redraw other column filters instead of showing all the values in that column of entire table.

I am looking like in this example

datatable

If I selected Singapore from Office column filter it's showing 4 records with 4 different positions, I am expecting only those 4 values in Position column filter. But it's giving all unique values of entire table.

Can someone help me how can i achieve this?

I have my code something as below:

$('#myTableId').DataTable( {
                colReorder : true,
                initComplete: function () {
                    this.api().columns([0,1]).every( function () {
                        var column = this;
                        var select = $('<select><option value="">All</option></select>')
                            .appendTo( $(column.footer()).empty() )
                            .on( 'change', function () {
                                var val = $.fn.dataTable.util.escapeRegex(
                                    $(this).val()
                                );

                                column
                                    .search( val ? '^'+val+'$' : '', true, false )
                                    .draw();
                            } );

                        column.data().unique().sort().each( function ( d, j ) {
                            select.append( '<option value="'+d+'">'+d+'</option>' )
                        } );
                    } );
                }
            } );  
over 3 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Show me some job opportunities
There's an error!