DataTables列过滤器

var table = $('#example').DataTable();
 
table.columns().flatten().each( function ( colIdx ) {
// Create the select list and search operation
var select = $('<select />')
    .appendTo(
        table.column(colIdx).footer()
    )
    .on( 'change', function () {
        table
            .column( colIdx )
            .search( $(this).val() )
            .draw();
    } );
 
// Get the search data for the first column and add to the select list
table
    .column( colIdx )
    .cache( 'search' )
    .sort()
    .unique()
    .each( function ( d ) {
        select.append( $('<option value="'+d+'">'+d+'</option>') );
    } );

  

原文地址:https://www.cnblogs.com/chengshuiqiang/p/4607893.html