server side jumping to specific page

server side jumping to specific page

confundidoconfundido Posts: 15Questions: 5Answers: 0

Got a pretty good server-side implementation going:

https://www.freecell.net/f/c/dbscores.html?game=8x4

But I've got a scenario I haven't totally managed to finesse. When folks want to see themselves in the scores list I would like to find them on the list on the server and then return the appropriate page of data and have the client set the pagination to that page.

After that the table should function normally allowing them to page forward/backward.

Not sure I totally explained that. But I've read a bunch of other things about setting specific pages and scrolling to a row, but I don't see that described for server side.

I've settled on this for a specific search but it's far from ideal.

https://www.freecell.net/f/c/dbscores.html?flavor=cur&game=8x4&user=Denny

I don't have a solid highlight on the selected user and it's not a fully functioning table at that point, it's just a funny little "frozen" window.

Any tips?

Thanks,

confundido

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    Hi @confundido ,

    This thread should help, it's asking the same thing.

    Cheers,

    Colin

  • confundidoconfundido Posts: 15Questions: 5Answers: 0

    Thanks for the fast response. Yeah, poster does sound like they have the same scenario and I think I read this before and didn't understand it. It seems like the poster ended up finding their own way.

    I re-read several times and still don't know exactly how to proceed. Do I make a separate AJAX call outside datatables to query the page number? And then I couldn't see from column.search() how I could specify things. So if I load the user's name and the name column into search, what does that generate for an AJAX call? I'll do a little spelunking but if there's any further guidance or info that might save the flailing that'd be great.

    Note: I tried lying in the return and setting "start" to the desired start record but that doesn't fool the client into displaying proper pagination. I know, I know, that's an input param but I thought maybe it'd be used in the return somehow. But that's the behavior I'm looking for-- I return the necessary slice and with"start" set and then it just shows the regular table as if that was the current page. That way the user can page forward and backwards normally after finding themselves.

    Thanks,

    confundido

  • confundidoconfundido Posts: 15Questions: 5Answers: 0

    I was using scroller before I went server-side. Is that an option? It seems to indicate it'll do server side.

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921
    edited October 2019 Answer ✓

    You can use Scroller with server side processing. Here is an example:
    https://datatables.net/extensions/scroller/examples/initialisation/server-side_processing.html

    It won't solve your problem of jumping to a specific row. Not sure I understand what the person did in the thread Colin linked to either. But I suspect the easiest way is to use an ajax request to the server with the data you want to jump to and have it perform the calculation and return the page number. You will probably need to send some paging info which you can get from the page.info() API.

    Kevin

  • confundidoconfundido Posts: 15Questions: 5Answers: 0

    Yeah, I think I got it figured out. I'll use scroller server-side and just make an initial call to get the row of the user and then call toPosition() on the table.

    I'll implement tomorrow. Thanks for the help.

    confundido

This discussion has been closed.