我正在使用jQuery数据表。

我想删除默认情况下添加到表中的搜索栏和页脚(显示有多少行可见)。我只是想用这个插件来排序。这能做到吗?


当前回答

没有过滤输入控件。(https://datatables.net/reference/option/dom)

    /* Results in:
        {length}
        {processing}
        {table}
        {information}
        {pagination}
    */
    $('#example').dataTable( {
      "dom": 'lrtip'
    } );

其他回答

你可以通过css隐藏它们:

#example_info, #example_filter{display: none}

没有过滤输入控件。(https://datatables.net/reference/option/dom)

    /* Results in:
        {length}
        {processing}
        {table}
        {information}
        {pagination}
    */
    $('#example').dataTable( {
      "dom": 'lrtip'
    } );

如果你正在使用themeroller:

.dataTables_wrapper .fg-toolbar { display: none; }

如果你正在使用自定义过滤器,你可能想隐藏搜索框,但仍然想启用过滤器功能,所以bFilter: false不是方法。使用dom: 'lrtp'代替,默认是'lfrtip'。文档:https://datatables.net/reference/option/dom

这可以通过简单地改变配置来完成:

$('table').dataTable({
      paging: false, 
      info: false
 });

但要隐藏空页脚;这段代码做到了:

 $('table').dataTable({
      paging: false, 
      info: false,

      //add these config to remove empty header
      "bJQueryUI": true,
      "sDom": 'lfrtip'

});