[RESOLVED] Datatables server-side problem to pagination (number of page not correct)

[RESOLVED] Datatables server-side problem to pagination (number of page not correct)

ersecchioersecchio Posts: 3Questions: 0Answers: 0
edited February 2015 in Free community support

Hi,
I have a problem with the datatables server-side ( DataTables 1.10.4 , jQuery v1.11.1 and Bootstrap v3.3.1 ).

I have inizialized the DataTable in this mode:

$('#datatables-4').dataTable( {
"processing": true,
"serverSide": true,
"order": [[ 3, "desc" ]],
"ajax": baseUrl+"shoes/ProcessingDatatables"
}

Records Totale is 216,,
The ajax response is:
draw: 1
recordsTotal: 216
recordsFiltered :10
data: array data etc etc.

The problem is that the number of pages is 1, but should be 22 pages ( 216 Records / 10 = 22 Pages).

This is the screenshots of the paging https://www.dropbox.com/s/9sx5iof4v0soau3/DataTables.png?dl=0

can you help?

ersecchio

Replies

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    The screenshot says

    Showing 1 to 10 of 10 entries (filtered from 216 total entries)
    

    so it is correct that pagination only has one page. You need to find out where you are applying a filter or query while retrieving the data.

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    recordsFiltered :10

    It should be 216 in this case unless you have a filter applied as @tangerine says.

    Allan

  • ersecchioersecchio Posts: 3Questions: 0Answers: 0
    edited February 2015

    At load of page the datatables sent via GET to the various parameters, the following
    ....
    length = 10
    order[0][column] 3
    order[0][dir] desc
    search[regex] false
    search[value]
    start = 0
    ...

    then "start" and "length".

    The controller of server inizialize the response variabile in this mode:
    "recordsTotal" = > Select all records from table, without filtering = SELECT * FROM table
    "recordsFiltered" => Select records from table with LIMIT, then "start" and "lenght" = SELECT * FROM table LIMIT 0, 10.
    "data" => array of 10 items

    and then
    recordsTotal: 216
    recordsFiltered :10

    maybe something wrong?

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    Yes - recordsFiltered is not the page length. It would be worth reading over the documentation for those parameters:

    recordsFiltered - Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned for this page of data).

    Allan

  • ersecchioersecchio Posts: 3Questions: 0Answers: 0

    RESOLVED.

    The "recordsFiltered" has a value different of "recordsTotal". The "recordsFiltred" is the number of items after globalSearch or columnSearch.

    If there is no search (globalSearch or columnSearch) , then the value "recordsFiltered" is equal to "recordsTotal".

    :)

This discussion has been closed.