Unending pagination pages with no data

Unending pagination pages with no data

MapleThunderMapleThunder Posts: 4Questions: 2Answers: 0
edited April 2017 in Free community support

DataTables V1.5, Phalcon V2.0.5

I'm using server-side code to generate the JSON to use for the data table but when the table populates it says there are pages that keep going, even without any data. It also says "Showing 0 to 0 of 0 entries".

I had to rewrite the parts of this script that referenced mysqli and replace it with Phalcon's method of access my database. The tables display their information correctly, even only showing the correct amount of records for each page. But the number of pages is incorrect (being unending and all), and the "Showing x to y of z" is also not working.

I've added the code below where as far as I can tell the only information relating to paging gets passed out to the front end.

list($iFilteredTotal) = count($items);

// Total data set length
list($iTotal) = count(\Item::find());


/**
 * Output
 */
$output = array(
    "sEcho"             => intval($input['sEcho']),
    "iTotalRecords"     => $iTotal,
    "iTotalDisplayRecords"  => $iFilteredTotal,
    "aaData"                => array(),
);

When I do a var_dump($output);die(); the "iTotalRecords" and "iTotalDisplayRecords" both show as null, if I remove the list() call wrapping the declarations then the var_dump() will show values for those fields, but the pagination no longer works at all and will only show the first 10 records returned.

Answers

  • MapleThunderMapleThunder Posts: 4Questions: 2Answers: 0

    I solved it, turns out I was assigning $iFilteredTotal with the same query that had the limit on it. I just reran the query with all of the filtering, except the limit, and it is now working perfectly.

This discussion has been closed.