【问题标题】:Change the value of "Show entries"- dropdown of datatables: "iDisplayLength" is not working更改“显示条目”的值 - 数据表的下拉列表:“iDisplayLength”不起作用
【发布时间】:2015-09-23 08:53:18
【问题描述】:

我一直在尝试编辑我的数据表的“显示条目”的下拉选项。默认值为 10,即页面包含 10 行,但我想首先在一页中显示所有行。我的代码如下:

$(document).ready(function () {
                $('#multiServiceJobTable').dataTable().columnFilter({
                     aoColumns: [
                                null,
                                {type: "select"},
                                {type: "select"},
                                {type: "select"},
                                {type: "select"},
                                {type: "select"},
                                {type: "select"},
                                {type: "select"}
                            ],
                             aLengthMenu: [
                                          [25, 50, 100, 200, -1],
                                          [25, 50, 100, 200, "All"]
                                          ],
                             iDisplayLength: -1
                });

                $('#multiServiceJobTable tfoot tr').insertAfter($('#multiServiceJobTable thead tr'));
        });

这是一个非常简单的表。我使用的是 1.9 版数据表。

【问题讨论】:

    标签: jquery datatables


    【解决方案1】:

    您以错误的顺序混合了选项:

    $('#multiServiceJobTable').dataTable({
       aLengthMenu: [
         [25, 50, 100, 200, -1],
         [25, 50, 100, 200, "All"]
       ],
       iDisplayLength: -1
    }).columnFilter({
       aoColumns: [
         null,
         {type: "select"},
         {type: "select"},
         {type: "select"},
         {type: "select"},
         {type: "select"},
         {type: "select"},
         {type: "select"}
       ]
    });
    

    正如您现在所拥有的,您将 aLengthMenu 等传递给 columnFilter 插件,而不是 dataTable 本身。

    【讨论】:

      猜你喜欢
      • 2014-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      • 2019-10-02
      • 1970-01-01
      • 2018-03-14
      相关资源
      最近更新 更多