我正在使用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}

我通过为footer分配一个id,然后使用css进行样式化来做到这一点:

    <table border="1" class="dataTable" id="dataTable_${dtoItem.key}" >
     <thead>
        <tr>
            <th></th>

        </tr>
    </thead>
 <tfoot>
    <tr>
            <th id="FooterHidden"></th>
    </tr>
</tfoot>
<tbody>

    <tr>

                <td class="copyableField"></td>

    </tr>
 </tbody>
</table>

然后使用CSS样式:

#FooterHidden{
   display: none;
}

如上所述的方法并不适合我。

如果你正在使用themeroller:

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

对于数据表>=1.10,使用:

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

如果你仍然想要这个插件的.search()函数,你需要用dom设置“隐藏”搜索栏html:

$('table').dataTable({dom: 'lrt'});

默认值是lfrtip或<"H"lfr>t<"F"ip>(当jQueryUI为true时),F char表示dom中的过滤(搜索)html, ip表示信息和分页(页脚)。

对于<1.10的数据表,使用:

$('table').dataTable({bFilter: false, bInfo: false});

或者使用纯CSS:

.dataTables_filter, .dataTables_info { display: none; }

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

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

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