如何在 jQuery DataTables 中完全抑制表头?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6732254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to suppress table headers completely in jQuery DataTables?
提问by mydoghasworms
I am using the DataTables plugin (www.datatables.net) for jQuery to display tables on a web page.
我正在使用 jQuery 的 DataTables 插件 (www.datatables.net) 在网页上显示表格。
After reading through the documentation and doing some searches, I am unable to find out how to completely suppress or hide table headers, using the DataTables options or API.
通读文档并进行一些搜索后,我无法找到如何使用 DataTables 选项或 API 完全抑制或隐藏表头。
回答by Nicola Peluchetti
Why don't you simply hide them through css (i think datatables requires a thead section to work)?
为什么不简单地通过 css 隐藏它们(我认为数据表需要一个 thead 部分才能工作)?
.dataTables_wrapper table thead{
display:none;
}
fiddle here: http://jsfiddle.net/LhZF3/
在这里小提琴:http: //jsfiddle.net/LhZF3/
回答by s.krueger
I know the question is pretty old, but I searched for it today and found another solution ...
我知道这个问题很老了,但我今天搜索了它并找到了另一个解决方案......
In your js / coffee file:
在你的 js/coffee 文件中:
$("#selector").dataTable({
... your other options ...
fnDrawCallback: -> $("#selector thead").remove()
})
Pure JS variant:
纯 JS 变体:
$("#selector").dataTable({
... your other options ...
fnDrawCallback: function() {
$("#selector thead").remove();
}
});
回答by Lucky
Simple add the style display:none
inline style to your thead tag.
简单地将样式display:none
内联样式添加到您的 thead 标签。
<thead style="display:none;">
</thead>
回答by Esa M?kinen
Just add this to your css:
只需将其添加到您的 css 中:
thead {
display:none;
}