streetlight
streetlight

Reputation: 5968

Get value of page in Datatables?

Does anyone know a way to get the value of the page that the user is on in Datatables? I'm trying to keep the page during a reload, but fnStandingRedraw and bStateSave aren't working for me, so I'm trying it manually.

Basically, I want to be able to store the variable, and then restore the user to that page. Problem is, I can't figure out to get the variable in the first place.

Any help would be appreciated!

Upvotes: 0

Views: 4118

Answers (3)

Samuel
Samuel

Reputation: 2520

In new API it is simple:

table.page();

Look here: https://datatables.net/reference/api/page%28%29

Upvotes: 1

Nand
Nand

Reputation: 11

fnDraw(false)

is better than getting and setting page number.

Upvotes: 0

streetlight
streetlight

Reputation: 5968

So I figured out how to get around this.

If you utilize fnPagingInfo (http://datatables.net/plug-ins/api#fnPagingInfo), it will send you the value of the page number.

Afterward, to send them to that page, just use fnPageChange and pass it the integer value you want (pages are 0 based in Datatables), and you should be well on your way. Also, this won't put any cookies in your browser!

Hope this helps anyone else with the same issue!

Upvotes: 1

Related Questions