DataTable分页无法正常工作 [英] DataTable paging is not working properly

查看:231
本文介绍了DataTable分页无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用DataTable



我已经问了几个关于它的问题,但仍然没有回答,所以我试图找出来并找到了第二个好东西。



我的选择似乎工作不正确。



例如:我有一张桌子10记录。页面的2条记录= 5页。表格显示我有5页和10条记录。在我的DataTable ajax中我有第二件事:



I'm trying to use DataTable

I already asked several questions about it, but still without answer, so I tried to figure it out and found a second thing.

My pagging seems to work incorrectly.

For example: I have a table with 10 records. 2 records for page = 5 pages. Table shows me that I have 5 pages and 10 total records. In my DataTable ajax I have second thing:

ajax: {
                ...
            data: function (d) {
                ...
                ...

                return {
                    take: d.length,
                    skip: d.start,
                    ordering: sorting.join(", "),
                    grouping: "",
                    draw: d.draw
                };
            }
        },



出于某种原因 - 每次点击其他页面时都会调用此选项,这会导致...从以前的页面记录和跳过所有内容。在结果中,我在所选页面上有正确的值,但在整个表格中我只能使用它们(没有其他记录而不是选定页面中的记录 - 因此我可以忘记搜索和等等。



如果我删除




For some reason - this is called each time I am clicking on another page, which results into... taking 2 records and skipping all from previous pages. In the result, I have correct values on the selected page, but in the whole table I am able to operate only with them (no another records instead of those in selected pages - so as a result I can forget about those things as search and etc).

If I remove

take: d.length,
skip: d.start,



然后,尽管有5页,每页显示我全部10条记录,我不知道为什么。



我在DataTable中也使用的东西(可能其中一些可能会导致问题,或者至少是每页重写整个表格的响应更改):




then, despite having 5 pages, each page shows me all 10 records, and I don't know why.

The things which I also use in DataTable (maybe some of those can cause issue, or at least be response for overdrawing entire table on each page change):

dom: 'T<"clear">rtsipl',
stateSave: true,
drawCallback:
initComplete:
processing: true,
serverSide: true,
pageLength: config.Paging.PageSize,
oLanguage: { "sInfo": "_START_ to _END_ of _TOTAL_ items", "sLengthMenu": "_MENU_ Items per page" },
scrollY: $(window).height() - $(window)[0].screenTop - 90,
scrollCollapse: true

推荐答案

(窗口).height() -
(window).height() -


(窗口)[0] .screenTop - 90,
scrollCollapse:true
(window)[0].screenTop - 90, scrollCollapse: true


这篇关于DataTable分页无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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