我正在使用jQuery数据表。

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


当前回答

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

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

其他回答

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

请访问http://www.datatables.net/examples/basic_init/filter_only.html查看要显示/隐藏的特性列表。

你想要的是将“bFilter”和“bInfo”设置为false;

$(document).ready(function() {
    $('#example').dataTable( {
        "bPaginate": false,
        "bFilter": false,
        "bInfo": false
                 } );
} );

在这里你可以添加到sDom元素到你的代码,顶部搜索栏是隐藏的。

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

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

var table = $("#datatable").DataTable({
   "paging": false,
   "ordering": false,
   "searching": false
});