Server side pagination problem

Server side pagination problem

CamelCamel Posts: 5Questions: 1Answers: 0

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

  • tangerinetangerine Posts: 1,913Questions: 8Answers: 210

    What do you mean by "deactive one record"?

  • kthorngrenkthorngren Posts: 1,565Questions: 18Answers: 322
    Answer ✓

    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

  • CamelCamel Posts: 5Questions: 1Answers: 0

    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

  • allanallan Posts: 43,134Questions: 1Answers: 5,608 Site admin

    Bugs are like busses - they all come along at the same time!

    Allan

  • CamelCamel Posts: 5Questions: 1Answers: 0

    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

  • btreebtree Posts: 81Questions: 11Answers: 11
    edited September 14

    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. :wink:

    Cheers
    Hannes

  • allanallan Posts: 43,134Questions: 1Answers: 5,608 Site admin

    Seems to work as expected for me here. @Camel - Can you link to a page showing the issue please.

    Allan

  • btreebtree Posts: 81Questions: 11Answers: 11

    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

  • allanallan Posts: 43,134Questions: 1Answers: 5,608 Site admin

    Thanks! However, I get "Wrong email or password!" when using those credentials.

    Allan

  • btreebtree Posts: 81Questions: 11Answers: 11

    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

  • allanallan Posts: 43,134Questions: 1Answers: 5,608 Site admin

    Hi Hannes,

    Just tried it again and same result. Its Chrome 60 / Linux (Fedora 26).

    Allan

  • CamelCamel Posts: 5Questions: 1Answers: 0
    edited September 15

    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: { ... },

  • btreebtree Posts: 81Questions: 11Answers: 11

    @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

  • allanallan Posts: 43,134Questions: 1Answers: 5,608 Site admin

    That worked this time - thanks.

    You have:

    "stateDuration": 0,

    So yup - the state would never be reloaded since it expires immediately.

    That it didn't before was a bug in older versions.

    Allan

  • btreebtree Posts: 81Questions: 11Answers: 11
    edited September 15

    @allan do i miss something, I want no timeLimit at all.
    https://datatables.net/reference/option/stateDuration

    The value 0 is a special value as it indicates that the state can be stored and retrieved indefinitely with no time limit.

    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?

  • allanallan Posts: 43,134Questions: 1Answers: 5,608 Site admin

    Urgh - I'm forgetting how my own code works - sorry. I'll need to dig into this and try to reproduce it.

    Allan

  • allanallan Posts: 43,134Questions: 1Answers: 5,608 Site admin
    Answer ✓

    I think we've got it sorted in this thread now. Thanks for flagging this up!

    Allan

  • CamelCamel Posts: 5Questions: 1Answers: 0

    Thx for quick fix & all answers!

Sign In or Register to comment.