api_scrolling.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 - API</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. initComplete: function () {
  28. var api = this.api();
  29. api.scroller().scrollToRow( 1000 );
  30. }
  31. } );
  32. } );
  33. </script>
  34. </head>
  35. <body class="dt-example">
  36. <div class="container">
  37. <section>
  38. <h1>Scroller example <span>API</span></h1>
  39. <div class="info">
  40. <p>This example shows a trivial use of the API methods that Scroller adds to the DataTables API to
  41. scroll to a row once the table's data has been loaded. In this case
  42. <code>scroller().scrollToRow()</code> is used to jump to row 1000.</p>
  43. </div>
  44. <table id="example" class="display" cellspacing="0" width="100%">
  45. <thead>
  46. <tr>
  47. <th>ID</th>
  48. <th>First name</th>
  49. <th>Last name</th>
  50. <th>ZIP / Post code</th>
  51. <th>Country</th>
  52. </tr>
  53. </thead>
  54. </table>
  55. <ul class="tabs">
  56. <li class="active">Javascript</li>
  57. <li>HTML</li>
  58. <li>CSS</li>
  59. <li>Ajax</li>
  60. <li>Server-side script</li>
  61. </ul>
  62. <div class="tabs">
  63. <div class="js">
  64. <p>The Javascript shown below is used to initialise the table shown in this
  65. example:</p><code class="multiline brush: js;">$(document).ready(function() {
  66. $('#example').DataTable( {
  67. ajax: &quot;data/2500.txt&quot;,
  68. deferRender: true,
  69. dom: &quot;frtiS&quot;,
  70. scrollY: 200,
  71. scrollCollapse: true,
  72. initComplete: function () {
  73. var api = this.api();
  74. api.scroller().scrollToRow( 1000 );
  75. }
  76. } );
  77. } );</code>
  78. <p>In addition to the above code, the following Javascript library files are loaded for use in this
  79. example:</p>
  80. <ul>
  81. <li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
  82. <li><a href=
  83. "../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
  84. <li><a href="../js/dataTables.scroller.js">../js/dataTables.scroller.js</a></li>
  85. </ul>
  86. </div>
  87. <div class="table">
  88. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by
  89. DataTables:</p>
  90. </div>
  91. <div class="css">
  92. <div>
  93. <p>This example uses a little bit of additional CSS beyond what is loaded from the library
  94. files (below), in order to correctly display the table. The additional CSS used is shown
  95. below:</p><code class="multiline brush: js;"></code>
  96. </div>
  97. <p>The following CSS library files are loaded for use in this example to provide the styling of the
  98. table:</p>
  99. <ul>
  100. <li><a href=
  101. "../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
  102. <li><a href="../css/dataTables.scroller.css">../css/dataTables.scroller.css</a></li>
  103. </ul>
  104. </div>
  105. <div class="ajax">
  106. <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
  107. will update automatically as any additional data is loaded.</p>
  108. </div>
  109. <div class="php">
  110. <p>The script used to perform the server-side processing for this table is shown below. Please note
  111. that this is just an example script using PHP. Server-side processing scripts can be written in any
  112. language, using <a href="//datatables.net/manual/server-side">the protocol described in the
  113. DataTables documentation</a>.</p>
  114. </div>
  115. </div>
  116. </section>
  117. </div>
  118. <section>
  119. <div class="footer">
  120. <div class="gradient"></div>
  121. <div class="liner">
  122. <h2>Other examples</h2>
  123. <div class="toc">
  124. <div class="toc-group">
  125. <h3><a href="./index.html">Examples</a></h3>
  126. <ul class="toc active">
  127. <li><a href="./simple.html">Basic initialisation</a></li>
  128. <li><a href="./state_saving.html">State saving</a></li>
  129. <li><a href="./large_js_source.html">Client-side data source (50,000 rows)</a></li>
  130. <li><a href="./server-side_processing.html">Server-side processing (5,000,000
  131. rows)</a></li>
  132. <li class="active"><a href="./api_scrolling.html">API</a></li>
  133. </ul>
  134. </div>
  135. </div>
  136. <div class="epilogue">
  137. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
  138. information about its API properties and methods.<br>
  139. Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
  140. <a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
  141. DataTables.</p>
  142. <p class="copyright">DataTables designed and created by <a href=
  143. "http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
  144. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  145. </div>
  146. </div>
  147. </div>
  148. </section>
  149. </body>
  150. </html>