Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82393

How to select the desire columns to sort

$
0
0

Greetins,

Was able to do a sort from the header in the table but will like to know how to determined what columns to use; i do not want to use all the columns for the sort.

JsFiddle File:
https://jsfiddle.net/trkq6hc3/

dataTable Code (Javascript):

$(document).ready(function() {
            $('.mydatatable').DataTable( {
                ordering:false,
                //
                initComplete:function(){
                    this.api().columns().every(function(){
                        var column = this;
                        var select = $('<select><option value=""></option></select>')
                            .appendTo($(column.header()).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>');
                        });

         
                    });
                }
                
            });
});

Viewing all articles
Browse latest Browse all 82393

Trending Articles