Datatable只显示10行,当50问
问题描述:
我希望我的数据表每页显示50行。Datatable只显示10行,当50问
我试图设置它:bLengthChange:true和pageLength:50但它没有工作。
在一个理想的世界,我也想摆脱bLengthChange的 - >假的,让我不明白的组合选择多少行做我想做...
这里是我的代码。
<html><body>
<head>
<link rel="stylesheet" href="//cdn.datatables.net/1.10.11/css/jquery.dataTables.min.css">
</head>
<body>
<table class="table responsive table-togglable table-hover">
<thead>
<tr>
<th data-toggle="true">ID</th>
<th >Usuario</th>
<th >Objeto</th>
<th >Id del Objeto</th>
<th class="none">Antes</th>
<th class="none">Despues</th>
<th >type</th>
<th >Creación</th>
<th >Actualización</th>
</tr>
</thead>
<tbody>
<tr>
<td>2165</td>
<td> - </td>
<td>PersonReferences</td>
<td>3802973</td>
<td> - </td>
<td> Large Text </td>
<td>created</td>
<td>2016-05-11 17:07:23</td>
<td>2016-05-11 17:07:23</td>
</tr>
</tbody>
</table>
<script src="http://rh.dev/assets/materialize/js/jquery-1.11.2.min.js"></script>
<script src="http://rh.dev/assets/js/datatables/datatables.min.js"></script>
<script src="http://rh.dev/assets/js/datatables/extensions/responsive.min.js"></script>
<script>
$('.table-togglable').DataTable({
bLengthChange: true,
pageLength: 50,
bInfo: false,
responsive: true,
"bAutoWidth": false,
});
</script>
任何想法?
答
可以使用iDisplayLength
为数据表1.10+:
行数使用分页时在一个页面上显示。如果启用了 功能(bLengthChange),则最终用户将能够使用弹出菜单将 覆盖到自定义设置。
$(".table-togglable").DataTable({
bLengthChange: true,
"lengthMenu": [ [10, 15, 25, 50, 100, -1], [10, 15, 25, 50, 100, "All"] ],
"iDisplayLength": 50,
bInfo: false,
responsive: true,
"bAutoWidth": false
});
嗨再次!!!你的小提琴可以工作,但我再一次不工作。要更改pageLength的组合不起作用。 (10,50,100),但排序和过滤器正在工作。 –
@JuliatzindelToro尝试添加'“lengthMenu”' – CMedina
它将条目添加到组合,但仍然不工作:( –