如何在 JQuery DataTable 中默认显示所有行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9443773/
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 show all rows by default in JQuery DataTable
提问by Radislav
Does anybody know how to show all rows by default in jQuery datatable?
有人知道如何在 jQuery 数据表中默认显示所有行吗?
I have tried this code, but it only shows 10 rows by default.
我试过这段代码,但默认情况下它只显示 10 行。
$("#adminProducts").dataTable({
"aLengthMenu": [100]
});
回答by LCoelho
Use:
用:
$('#example').dataTable({
aLengthMenu: [
[25, 50, 100, 200, -1],
[25, 50, 100, 200, "All"]
],
iDisplayLength: -1
});
Or if using 1.10+
或者如果使用 1.10+
$('#example').dataTable({
paging: false
});
回答by Bartek Koby?ecki
The option you should use is iDisplayLength:
您应该使用的选项是 iDisplayLength:
$('#adminProducts').dataTable({
'iDisplayLength': 100
});
回答by RHOUG
$('#table').DataTable({
"lengthMenu": [ [5, 10, 25, 50, -1], [5, 10, 25, 50, "All"] ]
});
回答by tenstormavi
This one works for me:
这个对我有用:
$(document).ready(function() {
$('#example').DataTable( {
"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
} );
} );
回答by th3byrdm4n
If you're using DataTables 1.10+ you can use the data-* attribute in your <table>
tag data-page-length="-1"
如果您使用的是 DataTables 1.10+,则可以在<table>
标签中 使用 data-* 属性data-page-length="-1"
This assumes you have "-1" defined in your datatable default configuration, such as below
这假设您在数据表默认配置中定义了“-1”,如下所示
$.extend(true, $.fn.dataTable.defaults, {
lengthMenu: [[10, 25, 50, 250, -1], [10, 25, 50, 250, "All"]]
});
Your javascript becomes simply $("table").DataTables();
and you're able to customize the display for every table within in the HTML; IE. if you have second, smaller table in the same page that should be limited to 10 rows, <table data-page-length="10">
您的 javascript 变得简单$("table").DataTables();
,您可以为 HTML 中的每个表自定义显示;IE。如果您在同一页面中有第二个较小的表,应限制为 10 行,<table data-page-length="10">
回答by Yoko Zunna
use 'fnDrawCallback'
使用'fnDrawCallback'
$('#dataTable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"fnInitComplete": function(){
$('.display_results').show();
},
"fnDrawCallback": function() {
$('.def').click(function(){
var msg = $(this).next().text();
$('.messages').messageBox()//Custom Dialog
});
}
})
回答by embulldogs99
Here is the entire functional javascript for your .html file
这是您的 .html 文件的完整功能 javascript
<!--- javascript -->
<script type="text/javascript">
$(document).ready(function(){
$('#sortable').dataTable({
'iDisplayLength': 100
})})
</script>
回答by Hamood K Alazri
you have to download the bootstrap-table.min.js and make some modification to it..
你必须下载 bootstrap-table.min.js 并对其进行一些修改..
If you download the bootstrap-table.min.js, just open it, and try to find "pageList:[10," make it as "pageList:[10,15,20,25,50,100,"All"]" make sure that "All" written as this.
Default page size can be changed as well from the same line "pageSize:10" you can change it as pageSize:"All".
Other options can be modified as well.
Don't forget to include it or linked to new place after completed your modification.
如果你下载了bootstrap-table.min.js,打开它,尝试找到“pageList:[10”,将其设为“pageList:[10,15,20,25,50,100,”All”]”确保“全部”这样写。
也可以从同一行“pageSize:10”更改默认页面大小,您可以将其更改为 pageSize:“All”。
也可以修改其他选项。
完成修改后,不要忘记包含它或链接到新位置。
I hope it is clear and easy enough to be done.
我希望这很清楚,很容易做到。