jQuery DataTables sDom 命令不起作用

jQuery DataTables sDom order not work

我需要左上角的 "filter" 和右上角的 "size",但不起作用:

$(document).ready(function() {
    jQuery('#example').dataTable({
            "sDom": '<"top"fl>rt<"bottom"ip><"clear">'
        });
} );

为什么?

SOLUTION

  • 使用这两个 CSS 规则来定位所有数据 tables:

    .dataTables_wrapper .dataTables_filter {
      float: left;
    }
    
    .dataTables_wrapper .dataTables_length {
      float: right;
    }
    
  • 使用这两个 CSS 规则来定位 #example 数据 table:

    #example_wrapper .dataTables_filter {
      float: left;
    }
    
    #example_wrapper .dataTables_length {
      float: right;
    }
    

DEMO

有关代码和演示,请参阅 this jsFiddle