我正在使用jQuery数据表。

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


当前回答

正如@Scott Stafford所说,sDOM是最适合显示、隐藏或重新定位组成数据表的元素的属性。我认为sDOM现在已经过时了,在实际的补丁中,这个属性现在是dom。

这个属性还允许为一个元素设置一些类或id,所以你可以更容易地设计风格。

查看官方文档:https://datatables.net/reference/option/dom

这个例子只显示表:

$('#myTable').DataTable({
    "dom": 't'
});

其他回答

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

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

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

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

您可以使用sDom属性。代码看起来像这样。

$(document).ready(function() {
    $('#example').dataTable( {
        'sDom': '"top"i'
                 } );
} );

İt隐藏搜索和寻呼机框。

我通过为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;
}

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

你可以通过css隐藏它们:

#example_info, #example_filter{display: none}