My m-datatable cannot paginate
April 28, 2018 at 12:10 amPosts: 14Member Reply #17202
I made my m-datatable with “remote” type, when I tried your source from https://keenthemes.com/metronic/preview/inc/api/datatables/demos/default.php, and use your code here https://keenthemes.com/metronic/preview/assets/demo/default/custom/components/datatables/base/data-ajax.js to load, the table run flawlessly, pagination works well.
Then I tried my self with my own data and with your response structure, I don’t know why my table show all result in one page, pagination not work. I attached files for my response and my code as well.
Please help, thanks
- This topic was modified 5 months, 3 weeks ago by renkawan. Reason: reupload code for load
Attachments:You must be logged in to view attached files.
April 28, 2018 at 2:59 amPosts: 2700Support Staff Reply #17218
Using remote data source, the pagination should be handled in the remote API.
Please check our demo backend API script, in docs/api_reference/, written in PHP.
May 10, 2018 at 11:31 amPosts: 14Member Reply #17478
I did pagination on my server, but I got another problem now, the pagination info (displaying data … of …) not working as your example. I don’t know why, please help. Please see this screenshot : https://ibb.co/neN3Ty
May 10, 2018 at 11:41 amPosts: 14Member Reply #17479
one more, I have set pageSize: 20, but I still got 10 data shown each page >_<
- This reply was modified 5 months, 1 week ago by renkawan. Reason: completing info
May 12, 2018 at 3:56 amPosts: 2700Support Staff Reply #17537
Have you properly recompile the assets using gulp?
Can you try to clear browser cache?
About the (displaying data … of …) issue, in your backend does it properly count the meta?
May 12, 2018 at 7:27 amPosts: 14Member Reply #17545
I think my meta data was right, here is :
$pagination = $_REQUEST["pagination"]; // From m-datatable
$data["meta"] = array(
"page" => $pagination["page"],
"pages" => round($my_total_data / $pagination["perpage"]),
"perpage" => $pagination["perpage"],
"total" => $my_total_data
Any advice or example that would help me?
May 12, 2018 at 5:07 pmPosts: 2700Support Staff Reply #17550
Our sample server script is in here docs/api_reference/,
Can you send your full backend server script? Let see if we can find something
May 12, 2018 at 10:41 pmPosts: 14Member Reply #17564
Hi, please look here for response : https://ibb.co/bMcd0d
And my script please look here : https://pastebin.com/3S14fYDk
May 13, 2018 at 4:56 amPosts: 2700Support Staff Reply #17565
Can you try to set this option to true?
May 13, 2018 at 8:26 amPosts: 14Member Reply #17567
I revised the script from serverSorting: false into serverSorting: true, still same. here my latest screenshot result : https://ibb.co/h90kfd
Please if any advice, thanks Jai
May 14, 2018 at 8:28 amPosts: 2700Support Staff Reply #17573
Can you check if the data count exactly received 20 items, same number as perpage?
May 15, 2018 at 8:43 pmPosts: 14Member Reply #17615This reply has been marked as private.
May 16, 2018 at 3:43 pmPosts: 2700Support Staff Reply #17641
Can you pass another key “pages” with total pages available on the server?
Please check sample backend script;
You can count it like this;
$pages = ceil($total / $perpage);
- This reply was modified 5 months, 1 week ago by Jai.
May 17, 2018 at 3:11 pmPosts: 14Member Reply #17669
Unfortunately still same, I’ll try analyze more then, and I’ll give you the updates soon. Thanks
You must be logged in to reply to this topic.