【问题标题】:Datatable's pagination plugin shows last index page numberDatatable 的分页插件显示最后一个索引页码
【发布时间】:2016-01-14 18:43:23
【问题描述】:

以下是我使用 jQuery 的 dataTable 插件的分页代码。 这段代码最后会产生一个额外的页码。

 $('#example').DataTable({
    "pagingType": "full_numbers",
    fnCreatedRow: function (nRow, aData, iDataIndex) {
        $("#example").find("td").addClass("ellipsis");
        var progressId = "#progressbar" + iDataIndex;
        $(progressId).progressbar({
            value: 37
        });

    },

    dom: '<"top"iflp<"clear">>rt',
    processing: true,
    serverSide: true,
    order: [[2, "asc"]],
    language: {
    "emptyTable": "<div class='TabletextRow' style='margin-left:6% !important'><div class='Icon-Nodata'></div> <div class='TableNodataText' style='margin-top:1% !important'> No Records Found.</div>", 
        "loadingRecords": "Loading...",
        "aria": {
            "sortascending": ": activate to sort column ascending",
            "sortdescending": ": activate to sort column descending"
        },
        "paginate": {
            "first": "First",
            "last": "Last",
            "next": ">>",
            "previous": "<<"
        },
    }

为了。例如:我们有 120 条记录,每页显示 10 条记录。但是我们可以在 UI 中看到第 12 页索引,即最后一页索引。我怎样才能删除它?

【问题讨论】:

  • 第十二页应包含项目#110-119...
  • 是的,它包含,但我不想在 UI 上显示 12。我怎样才能做到这一点?
  • 每个按钮都有可以在 css 中点击的属性/类,所以 display:none;指向该按钮的选择器。
  • 我可以这样做,但这不是可行的解决方案。当您在第 12 页时,将显示第一个索引页。

标签: javascript jquery pagination datatables


【解决方案1】:

原因

如果您有120 记录,则会有页面12 包含从111120 的记录。

显然您已将自定义样式应用于分页。在页面512 之间的默认样式中,还有省略号(...) 元素。您的 CSS 规则很可能会隐藏此元素。

有关代码和演示,请参阅this jsFiddle

解决方案

更正您的 CSS 规则以显示省略号 (...) 字符。

或者,请参阅my answer on how to remove ellipses 或文章jQuery DataTables – Pagination without ellipses

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-24
    • 2017-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多