Server side pagination problem
Server side pagination problem
INTRO
I ran into strange problem: my datatable is showing "Showing 11 to 10 of 10 entries " which is obviously nonsense. I think this could be kind of bug.
I am using PHP server side processing, stateSave: true, resetDisplay: false, processing: true, serverSide: true and some others which I believe are not important.
Let's assume I am showing just some active data, 11 records in total, page length 10 rows => 2 pages withou filter.
When I go to some editation form directly from datatable **second ** page and deactive one record and go back, I am getting message you can see above. AJAX parameters are start:10 and length:10.
Obviously, datatable tries to load / thinks I am still on second page which "doesn't exist" anymore.
The question is how can I handle this. I can handle it on server side like:
if (filteredCount === offset) {
offset = 0;
}
but I am still getting bad message. Thx for your thoughts!
This question has accepted answers - jump to:
Answers
What do you mean by "deactive one record"?
I might not understand your issue correctly but it sounds like the same behavior as discussed in this thread:
https://datatables.net/forums/discussion/comment/117240/#Comment_117240
Kevin
I am showing just some active data, it means that I am filtering some records from table which have column active = 1. By deactivate I mean setting this column active to 0. Basically it's the same as if I would delete some record.
Thx for link @kthorngren , this is exactly my case
https://datatables.net/forums/discussion/comment/117240/#Comment_117240
Bugs are like busses - they all come along at the same time!
Allan
OK, the problem was fixed in 1.10.16 but now stateSave: true stopped working.
When I am on eg. second page and I refresh it, I am back on first page. Sometimes it even serves me second page, but in pagination first page is selected.
I have tried it with previous version from my GIT and it worked.
Can someone confirm it? Thx
stateSave: true is working.
But yes seems like the start param is saved correctly but on refresh ignored.
Actually I like this behaviour, think I will remove the paging from being saved for my tables.
Cheers
Hannes
Seems to work as expected for me here. @Camel - Can you link to a page showing the issue please.
Allan
I'm not Camel but I got a "not" working Test case.
https://www.btree.at/beta/table/hive/
Login: demo_en@btree.at
PW: demo_en
Cheers
Hannes
Thanks! However, I get "Wrong email or password!" when using those credentials.
Allan
Hi Allan,
off topic sorry: You may found a bug in my beta page. Can you tell me which browser and version you use, because it works fine for me.
Thanks
Hannes
Hi Hannes,
Just tried it again and same result. Its Chrome 60 / Linux (Fedora 26).
Allan
I have just done some research and I found out, that problem is, when
responsive is set to true (responsive: true). I am using serverSide and AJAX is called twice. When I disable responsive extension, it's normally called just once.
I also commented all other javascript code to be sure that there is no problem somewhere else in my code.
I checked responsive extension with AJAX call here on this site, but it's working (strange).
Windows 10, Chrome 61.0.3163.91, Datatables 1.10.16, Responsive-2.2.0, datatable settings:
ajax: {
url: ajaxUrl,
type: "POST",
data: additionalData
},
resetDisplay: false,
processing: true,
serverSide: true,
responsive: true,
stateSave: true,
dom: 'Blfrtip',
buttons: [{ .... }],
columns: columns,
language: { ... },
@allan thank you and sorry cant replicate the problem. Login works fine on all major browser, but i don't have Fedora to test it.
I create a new user but dont think this is the problem.
Login: datatables@btree.at / PW: datatables
@Camel
Good spot did miss this. Yes the ajax is called two times with reponsive true, but only on first init.
I created a debug file, maybe this helps:
https://debug.datatables.net/ijavum
Cheers
Hannes
That worked this time - thanks.
You have:
So yup - the state would never be reloaded since it expires immediately.
That it didn't before was a bug in older versions.
Allan
@allan do i miss something, I want no timeLimit at all.
https://datatables.net/reference/option/stateDuration
Things like row sorting or page length are saved correctly on my page, so there must be a different thing?
PS.: Second do you also see the double ajax call on init?
Urgh - I'm forgetting how my own code works - sorry. I'll need to dig into this and try to reproduce it.
Allan
I think we've got it sorted in this thread now. Thanks for flagging this up!
Allan
Thx for quick fix & all answers!
Pagination issue still reproducible in latest version 1.10.20. This issue is same as this thread - https://datatables.net/forums/discussion/comment/117240/#Comment_117240
My settings are:
NOTE: Even after deleting the record from table the local storage values remains unchangeable.
@ashis82 Allan posted steps to reproduce the problem in that thread you posted, but that's no longer occurring, so it would suggest either the problem is fixed, or it's changed shape.
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
@colin Thanks for your quick reply.
Please login to this account.
https://demo.usesphere.com/admin/site/login
User: test@usesphere.com
Password: test1234
Reproducible steps:
1. Access people page from left menu (https://demo.usesphere.com/admin/leads/index)
2. Move to page 4 of the listing.
3. Select the check boxes and delete the record from the menu. Please make sure all the records from page 4 should be deleted.
Note: You can add records to datatable using "Add people" link available on top of listing.
Observation
- After deletion It still stays on the same page i.e. 4th page which yields to "No matching records found" message.
- As we use statesave=true, even after page refresh, it still shows the 4th page.
Datatable Settings:
Thank you for letting me know about this. It looks like an issue when using serverSide processing and state saving. I don't have an immediate fix, but have logged this in our issue tracker for the next release to address it.
Allan
@allan Thanks for your response. I will definitely wait for that fix.
Is there any link where I can track this issue. I have also subscribed to the github repo (https://github.com/DataTables/DataTables).
No, sorry, this is an internal system. The issue (DD-1342 for my reference) has this thread recorded against it, so we'll update here when it's progressed.
Colin
There is no update in the thread. Does it mean the bug still exists?
BTW, I've found this thread because of https://wordpress.org/support/topic/pagination-from-saved-state-is-reset-to-0/
Yep, sorry, the bug is still in the same state. I'll see if it can be expedited.
Colin
What we need to add is a mechanism for the server-side script to say that there is no data where data was requested (in terms of paging), but there is (or might be) data else where. In a similar vain, we've got a request to add the ability to indicate that there is more data available, but not putting a specific number on it. We'll probably be looking at these as part of our work on DataTables 2.
Allan