Search code examples
phpjquerytwitter-bootstrapbootstrap-table

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:

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

Here's where I got the table from:

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


Solution

  • CAUSE

    You have enabled server-side pagination with data-side-pagination="server" attribute for table element.

    SOLUTION #1

    Disable server-side pagination by removing data-side-pagination="server" attribute.

    • Remove data-side-pagination="server" attribute
    • 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. See the following examples:

    See this jsFiddle for code and demonstration.

    SOLUTION #2

    Implement pagination on the server. Among other parameters browser sends limit parameter containing number of records requested and offset parameter containing starting record.