• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

datatables current page

what would be the syntax to get the current page one is on?
for example say your datatables are showing 5 pages and you are on page 3 - how do i get page 3 as a var?
AND when I navigate away from the datatables webpage - how would I load page 3 on my return to the datatables webpage?
0
dgrafx
Asked:
dgrafx
  • 4
  • 3
1 Solution
 
darren-w-Commented:
Somthing like this:

<html>
    <head>
        <title></title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript">
            $(function() {
    var pathname = window.location.pathname;
    alert (pathname);
    $('body').append('<a href ="'+pathname+'">alink</a> ')
});
        </script>
    </head>
    <body></body>
</html>

Open in new window

0
 
dgrafxAuthor Commented:
no - i'm talking about the datatables "page" as in pagination
only the datatables area changes for next and prev links - the entire page does not reload
0
 
darren-w-Commented:
ok use

http://datatables.net/usage/features   
'bStateSave'  

$(document).ready( function () {
	$('#example').dataTable( {
		"bStateSave": true
	} );
} );

Open in new window

to remember the state of the page for when you return to it, gets saved to a cookie
D
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
dgrafxAuthor Commented:
i cant test this right now but thought i'd reply
if this saves the "page" to a cookie and then loads that same page when you come back - if navigating away - what about the filter?
does it populate the filter box and apply it as well?

thanks
0
 
darren-w-Commented:
Looks like it stores filter as well

Show details      Enable or disable state saving. When enabled a cookie will be used to save table display information such as pagination information, display length, filtering and sorting. As such when the end user reloads the page the display display will match what thy had previously set up.
0
 
dgrafxAuthor Commented:
thats awesome!
i will test that hopefully within 24 hours and get back to you

thanks
0
 
dgrafxAuthor Commented:
ok - looks good and thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now