Get page sent to server
Get page sent to server
krosoft
Posts: 8Questions: 0Answers: 0
Hello all
how I can get page# when user clicked on pagination button?
Thank you.
This discussion has been closed.
Replies
Please?
You can use
page()
to get the page number. The first page will be 0.Here is an example:
Kevin
Thank you
I try that:
and it display 0 which is OK but then I click on 1 (on the pagination) and nothing happened.
What I need is to somehow "know" on which page user clicked so I can send that to server.
Thank you for any help.
It works here for each page:
http://live.datatables.net/dohemisu/1/edit
Kevin
Your subject indicates you are using server side processing. I had to change the function a bit to work in a server side example. Take a look here:
http://live.datatables.net/suculuma/1/edit
Kevin
Awesome, thank you so much.
is serverSide set to true? if so, dataTables already send enough information for you to calculate the page (start and length). if start = 0 at any time, you are on page 1.
If start = 5 and length = 5 (length as in page length or offset) you are on page 2
Hello
yes, "serverSide"is set to true.
Your info looks interesting - do you have sample code, please?
if you do not run any interference, this link shows what is sent to the server and what it expects back https://datatables.net/manual/server-side
I modified @kthorngren example by adding console logging. Just make sure your console is open or that JSBin's console is open when you run it so you can explore what is sent and what is received
The data there is for an array of arrays.
If your data is an array of objects, it will be slightly different.
Hello @bindrid, thank you so much - do you have a link of your example?
I checked this one: http://live.datatables.net/suculuma/1/edit
and when I open console, I see only current page.
Thank you for your help.
Sorry about that, try this one http://live.datatables.net/kevahiho/1/edit
Most my server side work is done in c#. Here is the server side of the objects I deserialize the request into
And based on the data used in most datatable examples, this is the response objects
Thank you so much, now I see what you mean.
Btw. - what server you use?
My company uses IIS and our sites are a combination of VB.NET, C#, MVC for the back end and front end is combination of bootstrap/jquery and knockout js. and any number of plugins as we see fit.
OK thank you.