jQuery 过滤 dataTables.net 不包含过滤框输入
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9954510/
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
Filter dataTables.net without included filter-box input
提问by Pratyush
I want to use the filter function of DataTables, but don't want to use their search box with it.
我想使用DataTables的过滤功能,但不想使用他们的搜索框。
In their docsunder bFilter it says:
Note that if you wish to use filtering in DataTables this must remain 'true' - to remove the default filtering input box and retain filtering abilities, please use
请注意,如果您希望在 DataTables 中使用过滤,则必须保持“true” - 要删除默认过滤输入框并保留过滤功能,请使用
after which the sentence is left incomplete.
之后这句话不完整。
I tried:
我试过:
var oTable = $('#sortable').dataTable({
'bPaginate':false,
'bInfo':false,
'bFilter': true // displays Search box, setting false removes filter ability all together
});
$('#Accumulate').click(function(){
oTable.fnFilter("Accumulate");
});
回答by Daniel
You can also hide is using css class
您还可以隐藏正在使用的 css 类
<style type="text/css">
.dataTables_filter {
display: none;
}
</style>
回答by Greg Pettit
Pratyush,
普拉秋什,
Pure cosmetic showing and hiding of different UI elements is done with the sDom parameter:
不同 UI 元素的纯外观显示和隐藏是通过 sDom 参数完成的:
http://datatables.net/usage/options#sDom
http://datatables.net/usage/options#sDom
Note that the required syntax is different depending on if you're using jQuery UI or not.
请注意,所需的语法取决于您是否使用 jQuery UI。
回答by gavenkoa
Use (potentially speed up datatable initialization as avoid some calculation):
使用(可能会加速数据表的初始化以避免一些计算):
$("#table").dataTable({"bFilter": false});
or any sDomwithout foption (refer to official docs http://datatables.net/usage/options#sDomfor list of available options):
或任何没有f选项的sDom(有关可用选项的列表,请参阅官方文档http://datatables.net/usage/options#sDom):
$("#table").dataTable({"sDom": '...t...'});
Look for same options at official support site: http://datatables.net/forums/discussion/289/disable-search-filter-text-box
在官方支持站点寻找相同的选项:http: //datatables.net/forums/discussion/289/disable-search-filter-text-box
回答by Andrew Burns
"sDom": 'ltipr'
is the most simply of ways to do it.
是最简单的方法。
full example that I have used:
我使用过的完整示例:
oTable = $('#overview').dataTable(
{
"aoColumns":[
null,
null,
null,
null,
null,
{ "sSortDataType":"date-euro"},
{ "sSortDataType":"date-euro",},
null
],
"aaSorting":[],
"iDisplayLength": -1,
"aLengthMenu": [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
"sDom": 'ltipr'
}
);