state_saving.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
  6. <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
  7. <title>Scroller example - State saving</title>
  8. <link rel="stylesheet" type="text/css" href="../../../media/css/jquery.dataTables.css">
  9. <link rel="stylesheet" type="text/css" href="../css/dataTables.scroller.css">
  10. <link rel="stylesheet" type="text/css" href="../../../examples/resources/syntax/shCore.css">
  11. <link rel="stylesheet" type="text/css" href="../../../examples/resources/demo.css">
  12. <style type="text/css" class="init">
  13. </style>
  14. <script type="text/javascript" language="javascript" src="../../../media/js/jquery.js"></script>
  15. <script type="text/javascript" language="javascript" src="../../../media/js/jquery.dataTables.js"></script>
  16. <script type="text/javascript" language="javascript" src="../js/dataTables.scroller.js"></script>
  17. <script type="text/javascript" language="javascript" src="../../../examples/resources/syntax/shCore.js"></script>
  18. <script type="text/javascript" language="javascript" src="../../../examples/resources/demo.js"></script>
  19. <script type="text/javascript" language="javascript" class="init">
  20. $(document).ready(function() {
  21. $('#example').DataTable( {
  22. ajax: "data/2500.txt",
  23. deferRender: true,
  24. dom: "frtiS",
  25. scrollY: 200,
  26. scrollCollapse: true,
  27. stateSave: true
  28. } );
  29. } );
  30. </script>
  31. </head>
  32. <body class="dt-example">
  33. <div class="container">
  34. <section>
  35. <h1>Scroller example <span>State saving</span></h1>
  36. <div class="info">
  37. <p>Scroller will automatically integrate with DataTables in order to save the scrolling position of the
  38. table, if state saving is enabled in the DataTable (<a href=
  39. "//datatables.net/reference/option/stateSave"><code class="option" title=
  40. "DataTables initialisation option">stateSave<span>DT</span></code></a>). This example shows that in
  41. practice - to demonstrate, scroll the table and then reload the page.</p>
  42. </div>
  43. <table id="example" class="display" cellspacing="0" width="100%">
  44. <thead>
  45. <tr>
  46. <th>ID</th>
  47. <th>First name</th>
  48. <th>Last name</th>
  49. <th>ZIP / Post code</th>
  50. <th>Country</th>
  51. </tr>
  52. </thead>
  53. </table>
  54. <ul class="tabs">
  55. <li class="active">Javascript</li>
  56. <li>HTML</li>
  57. <li>CSS</li>
  58. <li>Ajax</li>
  59. <li>Server-side script</li>
  60. </ul>
  61. <div class="tabs">
  62. <div class="js">
  63. <p>The Javascript shown below is used to initialise the table shown in this
  64. example:</p><code class="multiline brush: js;">$(document).ready(function() {
  65. $('#example').DataTable( {
  66. ajax: &quot;data/2500.txt&quot;,
  67. deferRender: true,
  68. dom: &quot;frtiS&quot;,
  69. scrollY: 200,
  70. scrollCollapse: true,
  71. stateSave: true
  72. } );
  73. } );</code>
  74. <p>In addition to the above code, the following Javascript library files are loaded for use in this
  75. example:</p>
  76. <ul>
  77. <li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
  78. <li><a href=
  79. "../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
  80. <li><a href="../js/dataTables.scroller.js">../js/dataTables.scroller.js</a></li>
  81. </ul>
  82. </div>
  83. <div class="table">
  84. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by
  85. DataTables:</p>
  86. </div>
  87. <div class="css">
  88. <div>
  89. <p>This example uses a little bit of additional CSS beyond what is loaded from the library
  90. files (below), in order to correctly display the table. The additional CSS used is shown
  91. below:</p><code class="multiline brush: js;"></code>
  92. </div>
  93. <p>The following CSS library files are loaded for use in this example to provide the styling of the
  94. table:</p>
  95. <ul>
  96. <li><a href=
  97. "../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
  98. <li><a href="../css/dataTables.scroller.css">../css/dataTables.scroller.css</a></li>
  99. </ul>
  100. </div>
  101. <div class="ajax">
  102. <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
  103. will update automatically as any additional data is loaded.</p>
  104. </div>
  105. <div class="php">
  106. <p>The script used to perform the server-side processing for this table is shown below. Please note
  107. that this is just an example script using PHP. Server-side processing scripts can be written in any
  108. language, using <a href="//datatables.net/manual/server-side">the protocol described in the
  109. DataTables documentation</a>.</p>
  110. </div>
  111. </div>
  112. </section>
  113. </div>
  114. <section>
  115. <div class="footer">
  116. <div class="gradient"></div>
  117. <div class="liner">
  118. <h2>Other examples</h2>
  119. <div class="toc">
  120. <div class="toc-group">
  121. <h3><a href="./index.html">Examples</a></h3>
  122. <ul class="toc active">
  123. <li><a href="./simple.html">Basic initialisation</a></li>
  124. <li class="active"><a href="./state_saving.html">State saving</a></li>
  125. <li><a href="./large_js_source.html">Client-side data source (50,000 rows)</a></li>
  126. <li><a href="./server-side_processing.html">Server-side processing (5,000,000
  127. rows)</a></li>
  128. <li><a href="./api_scrolling.html">API</a></li>
  129. </ul>
  130. </div>
  131. </div>
  132. <div class="epilogue">
  133. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
  134. information about its API properties and methods.<br>
  135. Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
  136. <a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
  137. DataTables.</p>
  138. <p class="copyright">DataTables designed and created by <a href=
  139. "http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
  140. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  141. </div>
  142. </div>
  143. </div>
  144. </section>
  145. </body>
  146. </html>