简体   繁体   English

分页不适用于DataTables 1.10.7 / 1.10.11

[英]Pagination doesn't work with DataTables 1.10.7 / 1.10.11

I'm trying to enable server-side processing for data-tables and searching/sorting/chaning amount of rows work, everything except pagination 我正在尝试为数据表启用服务器端处理并搜索/排序/更改行数,除分页之外的所有内容

The setup for datatables is like this: 数据表的设置如下:

$('[data-table]').each(function() {
    var url = $(this).data("table");
    $(this).DataTable({
        "processing": true,
        "serverSide": true,
        "ajax": {
            url: url,
            type: 'POST'
        }
    });
})

Server side, the response looks like this: 服务器端,响应如下所示:

{
    data: […]
    draw: "12"
    recordsFiltered: 10
    recordsTotal: "208"
}

This is the result: 结果如下: 没有分页

And the funny thing is, if I ommit recordsFiltered and recordsTotal pagination work (kinda, last dosent work, but the rest does)... check these images: 而有趣的是,如果我ommit recordsFilteredrecordsTotal拼版作业(有点儿,最后dosent工作,但其余不)...看看这些图片:

分页没有总数

您只有10行,因此只有1页就没有分页。

"recordsTotal" and "recordsFiltered" should be the same value. “ recordsTotal”和“ recordsFiltered”应为相同的值。 So, if you have 160 total records in your table or query, yo should set the same value to the "recordsFiltered" parameter. 因此,如果表或查询中总共有160条记录,则应为“ recordsFiltered”参数设置相同的值。

This is a common misunderstanding, according to the docs. 根据文档,这是一个普遍的误解。 What the docs says and i think we all understand is that we should filter the records and set the "recordsFiltered" this count. 文档说的是什么,我认为我们都知道,我们应该过滤记录并设置“ recordsFiltered”此计数。

"Total records, after filtering (ie the total number of records after filtering has been applied - not just the number of records being returned for this page of data)." “过滤后的记录总数(即,应用过滤后的记录总数-不仅是该数据页面返回的记录数)。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM