Sorting and paggination
Sorting and paggination
Hey,
Im totally new to datatables and there is a possibility that my problem is my fault.
I have manage to sent JSON data to my datatables and it works (displaying part).
But i can't sort them or just display 10,25 or 50 of them.
Any ideas?
and my Php and JS code:
PHP
[code]
$users = getAllUsers();
$count = sizeof($users);
$arrayOfUsers =[];
$num = 1;
foreach($users as $curUser){
$arrayOfUsers[]=
array(
0 => $curUser->getFullName(),
1 => $curUser->getMail(),
2 => $curUser->getActivated(),
3 => "x",
"DT_RowId" => "row_".$num,
"DT_RowClass" => "gradeA"
);
$num++;
}
$output = array(
"sEcho" => 1,
"iTotalRecords" => $count,
"iTotalDisplayRecords" => $count,
"aaData" => $arrayOfUsers
);
echo json_encode($output);
?>
[/code]
and JS
[code]
$(document).ready(function() {
$('.datatable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "json.php"
} );
} );
[/code]
Thanks!!
Im totally new to datatables and there is a possibility that my problem is my fault.
I have manage to sent JSON data to my datatables and it works (displaying part).
But i can't sort them or just display 10,25 or 50 of them.
Any ideas?
and my Php and JS code:
PHP
[code]
$users = getAllUsers();
$count = sizeof($users);
$arrayOfUsers =[];
$num = 1;
foreach($users as $curUser){
$arrayOfUsers[]=
array(
0 => $curUser->getFullName(),
1 => $curUser->getMail(),
2 => $curUser->getActivated(),
3 => "x",
"DT_RowId" => "row_".$num,
"DT_RowClass" => "gradeA"
);
$num++;
}
$output = array(
"sEcho" => 1,
"iTotalRecords" => $count,
"iTotalDisplayRecords" => $count,
"aaData" => $arrayOfUsers
);
echo json_encode($output);
?>
[/code]
and JS
[code]
$(document).ready(function() {
$('.datatable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "json.php"
} );
} );
[/code]
Thanks!!
This discussion has been closed.
Replies
Allan
I have already figure it out.
But thank you anyway.