简体   繁体   English

表分页不正确且不限制记录-Bootstrap Datatable

[英]Table Pagination Incorrect and Not limiting records - Bootstrap Datatable

I have a bootstrap table that pulls json from another site and for some reason the pagination is incorrect: 我有一个引导表,该表从另一个站点提取json,并且由于某种原因分页不正确:

http://fragrate.net/index.php?queryp=&task=searchplayers http://fragrate.net/index.php?queryp=&task=searchplayers

If you see the bottom table: Data Loads correctly Clicking the records limit drop down doesn't limit records Clicking Page 2 Refreshes the table but the data doesn't change 如果您看到底部表格:数据正确加载单击记录限制下拉列表并不限制记录单击页面2刷新表格,但数据不会更改

Here's where I got the table from: 这是我从中得到桌子的地方:

http://wenzhixin.net.cn/p/bootstrap-table/docs/examples.html#pagination-table http://wenzhixin.net.cn/p/bootstrap-table/docs/examples.html#pagination-table

CAUSE 原因

You have enabled server-side pagination with data-side-pagination="server" attribute for table element. 您已使用table元素的data-side-pagination="server"属性启用了服务器端分页

SOLUTION #1 解决方案#1

Disable server-side pagination by removing data-side-pagination="server" attribute. 通过删除data-side-pagination="server"属性来禁用服务器端分页。

  • Remove data-side-pagination="server" attribute 删除data-side-pagination="server"属性
  • Change response format so that it only contains array of objects. 更改响应格式,使其仅包含对象数组。 According to the documentation : 根据文档

    Note that the required server response format is different depending on whether the sidePagination option is specified. 请注意,所需的服务器响应格式取决于是否指定了sidePagination选项。 See the following examples: 请参阅以下示例:

See this jsFiddle for code and demonstration. 有关代码和演示,请参见此jsFiddle

SOLUTION #2 解决方案#2

Implement pagination on the server. 在服务器上实现分页。 Among other parameters browser sends limit parameter containing number of records requested and offset parameter containing starting record. 在其他参数中,浏览器发送包含请求记录数的limit参数和包含起始记录的offset参数。

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

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