Pagination problem

Pagination problem

MarconianMarconian Posts: 5Questions: 0Answers: 0
edited September 2011 in General
Hello, people!

I'm new to DataTables and I'm facing a problem to copy and adapt a already working DataTables. I can already populate the table with data, but the pagination isn't working properly. I believe it's a problem with iTotalRecords and iTotalDisplayRecords, but I'm not sure.

The working table is: http://myminnesotagolfcourses.com/minnesota-golf-course-directory/
Whose data is from: http://myminnesotagolfcourses.com/minnesota-golf-course-directory/lib/server_processing.php

It says "Showing 1 to 25 of 482 Results (filtered from 1 total entries)", which is correct because there are 482 records.

The NOT YET fully working table is: http://myminnesotagolfcourses.com/minnesota-golf-course-reviews/
Whose data is from: http://myminnesotagolfcourses.com/minnesota-golf-course-reviews/server_processing.php

It says "Showing 1 to 25 of 25 Results (filtered from 1 total entries)", which is wrong because there are the same 482 records. I believe this is somehow related to the pagination problem, as it's only showing one page in the pagination and the Prev/Next/First/Last buttons don't work. However, if I select to show all records (instead of only 25), all the 482 records are displayed.

I couldn't figure it out why the pagination isn't working, because both data strings are pretty similar. If you need any other information, please ask.

Thanks in advance for any kind of help.

-
Marcos Alves

Replies

  • GregPGregP Posts: 500Questions: 10Answers: 0
    edited September 2011
    Yup, there are some problems!

    In both samples, "(filtered from 1 total entries) is incorrect; you have 482 records. Then in the second sample, as you already know, '25 Results' is incorrect. If you have not done any filtering (searches), the output should look like:

    "Showing 1 to 25 of 482 Results (filtered from 482 total entries)"

    Your server-side should be returning 482 for iTotalRecords (the total number of records before filtering), and assuming you have not filtered, it should also return 482 for iTotalDisplayRecords (total number of filtered records available; paginating into groups of 25 is NOT filtering so don't be thrown off by the "Display" part of the parameter name).

    If you did a search that narrowed your list down to 79 records, the output should look like:

    "Showing 1 to 25 of 79 Results (filtered from 482 total entries)"

    To reiterate:

    iTotalRecords = your grand total number of records
    iTotalDisplayRecords = total number of records after filtering, regardless of pagination
  • MarconianMarconian Posts: 5Questions: 0Answers: 0
    Thanks for the quick reply, GregP!

    I followed your instructions and fixed the problem. I also fixed the "working" table. Now the "filtered from" doesn't show anymore, because iTotalRecors is the same as iTotalDisplayRecords, I believe.

    Thanks a lot!

    -
    Marcos Alves
  • GregPGregP Posts: 500Questions: 10Answers: 0
    Glad to help! Had to learn these parameters myself recently, so they were fresh in my mind.
This discussion has been closed.