当询问50条数据表时,它仅显示10行 [英] Datatable only display 10 rows, when 50 asked

查看:70
本文介绍了当询问50条数据表时,它仅显示10行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的数据表每页显示50行.

I want my datatable to display 50 rows per page.

我尝试设置为:bLengthChange:true和pageLength:50,但是没有用.

I tried to set it with : bLengthChange: true and pageLength: 50 but it didn't work.

在理想的世界中,我也将摆脱bLengthChange-> false,这样我就不会看到用来选择我想要多少行的组合...

In an ideal world, I would also get rid of the bLengthChange -> false, so that I don't see the combo to select how much rows do I want...

这是我的代码.

<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&oacute;n</th>
        <th >Actualizaci&oacute;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用于 DataTables 1.10 + :

使用分页时要在单个页面上显示的行数.如果 功能启用(bLengthChange),则最终用户将能够 使用弹出菜单将其覆盖为自定义设置.

Number of rows to display on a single page when using pagination. If feature enabled (bLengthChange) then the end user will be able to override this to a custom setting using a pop-up menu.

$(".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
});

结果: https://jsfiddle.net/cmedina/7kfmyw6x/50/

这篇关于当询问50条数据表时,它仅显示10行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆