dataTables bottstrap issues with pagination

dataTables bottstrap issues with pagination

djomladjomla Posts: 3Questions: 0Answers: 0
edited March 2013 in Bug reports
I copied example from site too test how it works etc. But i'm having issues with pagination.
It's not working.

http://invision.hr/dataTables/tables.html

Here is the live example.
And here is my php implementation

[code]
$columns_num = 5;

$offset = (empty($_GET['iDisplayStart'])) ? 0 : $_GET['iDisplayStart'];
$limit = (empty($_GET['iDisplayLength'])) ? 10 : $_GET['iDisplayLength'];

$show_total = 200;
$return_data = array();

function getrandomstring($length) {
global $template;
settype($template, "string");

$template = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
/* this line can include numbers or not */

settype($length, "integer");
settype($rndstring, "string");
settype($a, "integer");
settype($b, "integer");

for ($a = 0; $a <= $length; $a++) {
$b = rand(0, strlen($template) - 1);
$rndstring .= $template[$b];
}

return $rndstring;
}


for ($i = $offset; $i <= ($offset+$limit); $i++) {
$data = array();
$data[] = $i;
for ($a = 1; $a < $columns_num; $a++) {
$data[] = getrandomstring(6);
}

$return_data['aaData'][] = $data;
}

$return_data["sEcho"] = 1;
$return_data["iTotalRecords"] = $show_total;
$return_data["iTotalDisplayRecords"] = $show_total;


echo json_encode($return_data);exit;
[/code]


I'm just sending random data in array...it's straightforward just for this test.

What am i doing wrong?

Replies

  • djomladjomla Posts: 3Questions: 0Answers: 0
    Why do you say it's integrated with bootstrap when it's not working??
  • allanallan Posts: 63,381Questions: 1Answers: 10,449 Site admin
    Looks like the Bootstrap integration is working just fine to me. You've not implemented server-side processing fully though. Specifically sEcho. From the documentation ( http://datatables.net/usage/server-side ):

    > An unaltered copy of sEcho sent from the client side. This parameter will change with each draw

    Your server-side script is always returning 1.

    Allan
  • djomladjomla Posts: 3Questions: 0Answers: 0
    Hi Allan,


    Yes now it works! Thank you very much. I just think that it should be more clear about the 'sEcho' because 'unaltered' seems really unclear for me an confusing.

    Thank you.
This discussion has been closed.