我正在使用jQuery数据表。

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


当前回答

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

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

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

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

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

});

其他回答

你可以通过css隐藏它们:

#example_info, #example_filter{display: none}
$('#my_table').DataTable({
   "iDisplayLength": 100,
   "searching": false, 
   "paging": false,
   "info": false,
});

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

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

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

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

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

});

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

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

如果你只是想隐藏搜索表单,例如,因为你有列输入过滤器,或者可能是因为你已经有一个CMS搜索表单能够从表中返回结果,那么你所要做的就是检查表单并获得它的id -(在写这篇文章的时候,它看起来像这样[tableid]-table_filter. datatables_filter)。然后简单地执行[tableid]-table_filter.dataTables_filter{display:none;}保留数据表的所有其他特性。