Server-side last page issue

Server-side last page issue

yveteeyvetee Posts: 29Questions: 7Answers: 0

live.datatables.net/jobihota/3/

i am trying to make on load, move to last page.

i am here so far, any help.

as you will see, i am using timer to move in last page. I want on load to move to last.

Answers

  • yveteeyvetee Posts: 29Questions: 7Answers: 0

    in my demo, you will notice that the page load and then it moves to last page. There is for 1sec that the users see data changing.

  • yveteeyvetee Posts: 29Questions: 7Answers: 0
    edited April 2020

    issue?

  • yveteeyvetee Posts: 29Questions: 7Answers: 0
    edited April 2020

    http://live.datatables.net/jobihota/4/edit

    update demo,
    see first page data but pagination is last!!!

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Yep, it will do that. The table is loading initially, then you're making another call to the server to move to the final page. That's unavoidable, but you could change the sort order so the last page becomes the first to avoid that second page transition.

    Colin

  • kthorngrenkthorngren Posts: 21,726Questions: 26Answers: 5,027

    Seems like you need that initial table load to get the page.info(). Also in your second example that draw() appears to happen too quickly and the XHR request is never sent so I think you will need the short timeout like your first example. Another thing you could do is hide the table then show it in initComplete. Maybe this example will give you some ideas:
    http://live.datatables.net/yodasuro/1/edit

    Note also the use of api.one('draw', function () { ... }) for a one time event to show the hidden table.

    Kevin

  • yveteeyvetee Posts: 29Questions: 7Answers: 0

    Thank you Kevin,

    i am trying all day to load the page on last page. Trying everything and stack. My best solution so far was with a timer. But it is not acceptable as it showing data for a second and then reload. The only solution is load the page in last page. Simple fast. I can't understand why it is so hard. In the last 2 hours, i was thinking to use another datatable as there is no support in the community. i will think to use pure code and move on.

  • kthorngrenkthorngren Posts: 21,726Questions: 26Answers: 5,027
    edited April 2020

    Actually here is a better solution:
    http://live.datatables.net/yodasuro/3/edit

    Hide the div that the table is in then show it after the data is drawn. It is much smoother. Also I set the timeout to 0. For some reason it just needs a small delay so the api.page(info.pages - 1).draw(false); will send an Ajax request. There must be a race condition, without the delay, that inhibits the ajax request.

    i was thinking to use another datatable as there is no support in the community

    It is the weekend :smile: There is good support in the community. Hope you stick with Datatables as its a good product and the developers are the best.

    Kevin

  • yveteeyvetee Posts: 29Questions: 7Answers: 0

    Hello Kevin,

    Thank you for the support. Your solution is something but doesn't fix my issue.

    I repost my first issues and hope to have an answer.

    Meanwile, i will start from scratch my page again, as i lost 10days trying to fix issues with datatables and searching web.

    I can have same result with jquery,ajax and bootstrap tables. Plus, free support by the community in many blogs/forums.

    I desided to update my old private app since i have time due to Covid-19 but never thought it will be a nightmare. Now, i don't have a new one, plus didn't update the old one... Tried to find support to well known forums, but noone answer.

    Thank you for your time and help.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I can't see what's wrong with the solution Kevin suggested in his last post - that works perfectly. But yep, all the best, hope you find a working solution.

    Colin

  • yveteeyvetee Posts: 29Questions: 7Answers: 0

    Colin,

    thank you for your message.

    i am posting your private message

    "We offer support packages for expedited support - please see here."

    Colin, i am a user and not a company.

    The only support users can find for datatables is here and you gave the answer...

This discussion has been closed.