Scroller.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-type" content="text/html; charset=utf-8">
  5. <title>Class: Scroller - documentation</title>
  6. <style type="text/css" media="screen">
  7. @import "media/css/doc.css";
  8. @import "media/css/shCore.css";
  9. @import "media/css/shThemeDataTables.css";
  10. </style>
  11. <script type="text/javascript" src="media/js/shCore.js"></script>
  12. <script type="text/javascript" src="media/js/shBrushJScript.js"></script>
  13. <script type="text/javascript" src="media/js/jquery.js"></script>
  14. <script type="text/javascript" src="media/js/doc.js"></script>
  15. </head>
  16. <body>
  17. <div class="fw_container">
  18. <a name="top"></a>
  19. <div class="fw_header">
  20. <h1 class="page-title">Class: Scroller</h1>
  21. <div class="page-info">
  22. Scroller v1.1.0 documentation
  23. </div>
  24. </div>
  25. <div class="fw_nav">
  26. <h2>Navigation</h2>
  27. <ul>
  28. <li><a href="#top">Overview</a></li>
  29. <li><a href="#summary">Summary</a><div><table cellpadding="5" border="0" cellspacing="0" width="100%"><tbody><tr><td>Classes (0)</td><td><a href="#summary_namespaces">Namespaces (3)</a></td></tr><tr><td><a href="#summary_properties">Properties (1)</a></td><td><a href="#summary_properties_static">Static properties (1)</a></td></tr><tr><td><a href="#summary_methods">Methods (4)</a></td><td>Static methods (0)</td></tr><tr><td>Events (0)</td><td></td></tr></tbody></table></div></li><li><a href="#details">Details</a><div><table cellpadding="5" border="0" cellspacing="0" width="100%"><tbody><tr><td><a href="#summary_properties">Properties (1)</a></td><td><a href="#summary_properties_static">Static properties (1)</a></td></tr><tr><td><a href="#summary_methods">Methods (4)</a></td><td>Static methods (0)</td></tr><tr><td>Events (0)</td><td></td></tr></tbody></table></div></li></ul>
  30. <div style="margin-top: 10px;">
  31. <input type="hidden" name="show_private" value="0">
  32. <span id="private_label">Hiding</span> private elements
  33. (<a id="private_toggle" href="">toggle</a>)
  34. </span>
  35. </div>
  36. <div>
  37. <input type="hidden" name="show_extended" value="1">
  38. <span id="extended_label">Showing</span> extended elements
  39. (<a id="extended_toggle" href="">toggle</a>)
  40. </span>
  41. </div>
  42. </div>
  43. <div class="fw_content">
  44. <a name="overview"></a>
  45. <div class="doc_overview">
  46. <div class="nav_blocker"></div>
  47. <dl><dt id="Scroller" class=" even"><a name="Scroller"></a><a name="Scroller_details"></a><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a>new Scroller</a></span><span class="type-sig"><span class="signature">(oDT, <span class="optional">oOpts</span>)</span><span class="type-signature"></span></span></span></dt><dd class=" even"><p>Scroller is a virtual rendering plug-in for DataTables which allows large
  48. datasets to be drawn on screen every quickly. What the virtual rendering means
  49. is that only the visible portion of the table (and a bit to either side to make
  50. the scrolling smooth) is drawn, while the scrolling container gives the
  51. visual impression that the whole table is visible. This is done by making use
  52. of the pagination abilities of DataTables and moving the table around in the
  53. scrolling container DataTables adds to the page. The scrolling container is
  54. forced to the height it would be for the full table display using an extra
  55. element. </p>
  56. <p>Note that rows in the table MUST all be the same height. Information in a cell
  57. which expands on to multiple lines will cause some odd behaviour in the scrolling.</p>
  58. <p>Scroller is initialised by simply including the letter 'S' in the sDom for the
  59. table you want to have this feature enabled on. Note that the 'S' must come
  60. AFTER the 't' parameter in sDom.</p>
  61. <p>Key features include:
  62. <ul class="limit_length">
  63. <li>Speed! The aim of Scroller for DataTables is to make rendering large data sets fast</li>
  64. <li>Full compatibility with deferred rendering in DataTables 1.9 for maximum speed</li>
  65. <li>Correct visual scrolling implementation, similar to "infinite scrolling" in DataTable core</li>
  66. <li>Integration with state saving in DataTables (scrolling position is saved)</li>
  67. <li>Easy to use</li>
  68. </ul></p><div class="collapse_details"><h3>Constructor</h3><dl class="details">
  69. </dl>
  70. <h5>Parameters:</h5>
  71. <table class="params">
  72. <thead>
  73. <tr>
  74. <th width="20"></th>
  75. <th width="12%" class="bottom_border name">Name</th>
  76. <th width="10%" class="bottom_border">Type</th>
  77. <th width="10%" class="bottom_border">Attributes</th>
  78. <th width="10%" class="bottom_border">Default</th>
  79. <th class="last bottom_border">Description</th>
  80. </tr>
  81. </thead>
  82. <tbody>
  83. <tr class="even"><td class="number right_border"><div>1</div></td><td class="name">oDT</td><td class="type type-param">object</td><td class="attributes"></td><td class="default"></td><td class="description last"><p>DataTables settings object</p></td></tr><tr class="odd"><td class="number right_border"><div>2</div></td><td class="name">oOpts</td><td class="type type-param">object</td><td class="attributes">Optional</td><td class="default">{}</td><td class="description last"><p>Configuration object for FixedColumns. Options are defined by <a href="Scroller.oDefaults.html">Scroller.oDefaults</a></p></td></tr>
  84. </tbody>
  85. </table><h5>Example:</h5>
  86. <div class="example-code">
  87. <pre class="brush: js"> $(document).ready(function() {
  88. $('#example').dataTable( {
  89. "sScrollY": "200px",
  90. "sAjaxSource": "media/dataset/large.txt",
  91. "sDom": "frtiS",
  92. "bDeferRender": true
  93. } );
  94. } );</pre>
  95. </div>
  96. </div>
  97. </dl><h3 class="subsection-title">Requires</h3>
  98. <ul>
  99. <li>module:jQuery</li><li>module:DataTables</li>
  100. </ul>
  101. </div>
  102. <div class="doc_summary">
  103. <a name="summary"></a>
  104. <h2>Summary</h2>
  105. <div class="doc_group"><a name="summary_namespaces"></a><h3 class="subsection-title">Namespaces</h3>
  106. <dl>
  107. <dt class="even"><span class="type-name"><a href="c6053fac6b.html">dom</a></span></dt><dd class="even"><p>DOM elements used by the class instance</p></dd><dt class="odd"><span class="type-name"><a href="Scroller.oDefaults.html">oDefaults</a></span></dt><dd class="odd"><p>Scroller default settings for initialisation</p></dd><dt class="even"><span class="type-name"><a href="baed189d4a.html">s</a></span></dt><dd class="even"><p>Settings object which contains customisable information for the Scroller instance</p></dd>
  108. </dl></div><div class="doc_group"><a name="summary_properties"></a><h3 class="subsection-title">Properties - instance</h3>
  109. <dl>
  110. <dt class=" even"><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a href="#CLASS">CLASS</a></span><span class="type-sig"><span class="type-signature"> :String</span></span></dt><dd class=" even"><p>Name of this class</p></dd>
  111. </dl></div><div class="doc_group"><a name="summary_properties_static"></a><h3 class="subsection-title">Properties - static</h3>
  112. <dl>
  113. <dt class=" even"><span class="type-attr"><span class="type-signature">&lt;static> </span></span><span class="type-name"><a href="#VERSION">VERSION</a></span><span class="type-sig"><span class="type-signature"> :String</span></span></dt><dd class=" even"><p>Scroller version</p></dd>
  114. </dl></div><div class="doc_group"><a name="summary_methods"></a><h3 class="subsection-title">Methods - instance</h3>
  115. <dl>
  116. <dt class=" even"><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a href="#fnMeasure">fnMeasure</a></span><span class="type-sig"><span class="signature">(<span class="optional">bRedraw</span>)</span><span class="type-signature"> &rarr; {void}</span></span></dt><dd class=" even"><p>Calculate and store information about how many rows are to be displayed in the scrolling
  117. viewport, based on current dimensions in the browser's rendering. This can be particularly
  118. useful if the table is initially drawn in a hidden element - for example in a tab.</p></dd><dt class=" odd"><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a href="#fnPixelsToRow">fnPixelsToRow</a></span><span class="type-sig"><span class="signature">(iPixels)</span><span class="type-signature"> &rarr; {int}</span></span></dt><dd class=" odd"><p>Calculate the row number that will be found at the given pixel position (y-scroll)</p></dd><dt class=" even"><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a href="#fnRowToPixels">fnRowToPixels</a></span><span class="type-sig"><span class="signature">(iRow)</span><span class="type-signature"> &rarr; {int}</span></span></dt><dd class=" even"><p>Calculate the pixel position from the top of the scrolling container for a given row</p></dd><dt class=" odd"><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a href="#fnScrollToRow">fnScrollToRow</a></span><span class="type-sig"><span class="signature">(iRow, <span class="optional">bAnimate</span>)</span><span class="type-signature"> &rarr; {void}</span></span></dt><dd class=" odd"><p>Calculate the row number that will be found at the given pixel position (y-scroll)</p></dd>
  119. </dl>
  120. </div>
  121. </div>
  122. <div class="doc_details">
  123. <a name="details"></a>
  124. <h2>Details</h2>
  125. <div class="doc_group"><a name="details_properties"></a><h3 class="subsection-title">Properties - instance</h3>
  126. <dl>
  127. <dt class=" even"><a name="CLASS"></a><a name="CLASS_details"></a><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a href="#CLASS">CLASS</a></span><span class="type-sig"><span class="type-signature"> :String</span></span></dt><dd class=" even"><p>Name of this class</p><div class="collapse_details"><dl class="details">
  128. </dl>
  129. </div></dd>
  130. </dl></div><div class="doc_group"><a name="details_properties"></a><h3 class="subsection-title">Properties - static</h3>
  131. <dl>
  132. <dt class=" even"><a name="VERSION"></a><a name="VERSION_details"></a><span class="type-attr"><span class="type-signature">&lt;static> </span></span><span class="type-name"><a href="#VERSION">VERSION</a></span><span class="type-sig"><span class="type-signature"> :String</span></span></dt><dd class=" even"><p>Scroller version</p><div class="collapse_details"><dl class="details">
  133. </dl>
  134. </div></dd>
  135. </dl></div><div class="doc_group"><a name="details_methods"></a><h3 class="subsection-title">Methods - instance</h3>
  136. <dl>
  137. <dt id="Scroller#fnMeasure" class=" even"><a name="fnMeasure"></a><a name="fnMeasure_details"></a><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a>fnMeasure</a></span><span class="type-sig"><span class="signature">(<span class="optional">bRedraw</span>)</span><span class="type-signature"> &rarr; {void}</span></span></span></dt><dd class=" even"><p>Calculate and store information about how many rows are to be displayed in the scrolling
  138. viewport, based on current dimensions in the browser's rendering. This can be particularly
  139. useful if the table is initially drawn in a hidden element - for example in a tab.</p><div class="collapse_details"><dl class="details">
  140. </dl>
  141. <h5>Parameters:</h5>
  142. <table class="params">
  143. <thead>
  144. <tr>
  145. <th width="20"></th>
  146. <th width="12%" class="bottom_border name">Name</th>
  147. <th width="10%" class="bottom_border">Type</th>
  148. <th width="10%" class="bottom_border">Attributes</th>
  149. <th width="10%" class="bottom_border">Default</th>
  150. <th class="last bottom_border">Description</th>
  151. </tr>
  152. </thead>
  153. <tbody>
  154. <tr class="even"><td class="number right_border"><div>1</div></td><td class="name">bRedraw</td><td class="type type-param">bool</td><td class="attributes">Optional</td><td class="default">true</td><td class="description last"><p>Redraw the table automatically after the recalculation, with
  155. the new dimentions forming the basis for the draw.</p></td></tr>
  156. </tbody>
  157. </table><h5>Example:</h5>
  158. <div class="example-code">
  159. <pre class="brush: js"> $(document).ready(function() {
  160. // Make the example container hidden to throw off the browser's sizing
  161. document.getElementById('container').style.display = "none";
  162. var oTable = $('#example').dataTable( {
  163. "sScrollY": "200px",
  164. "sAjaxSource": "media/dataset/large.txt",
  165. "sDom": "frtiS",
  166. "bDeferRender": true,
  167. "fnInitComplete": function (o) {
  168. // Immediately scroll to row 1000
  169. o.oScroller.fnScrollToRow( 1000 );
  170. }
  171. } );
  172. setTimeout( function () {
  173. // Make the example container visible and recalculate the scroller sizes
  174. document.getElementById('container').style.display = "block";
  175. oTable.fnSettings().oScroller.fnMeasure();
  176. }, 3000 );</pre>
  177. </div>
  178. </div>
  179. <dt id="Scroller#fnPixelsToRow" class=" odd"><a name="fnPixelsToRow"></a><a name="fnPixelsToRow_details"></a><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a>fnPixelsToRow</a></span><span class="type-sig"><span class="signature">(iPixels)</span><span class="type-signature"> &rarr; {int}</span></span></span></dt><dd class=" odd"><p>Calculate the row number that will be found at the given pixel position (y-scroll)</p><div class="collapse_details"><dl class="details">
  180. </dl>
  181. <h5>Parameters:</h5>
  182. <table class="params">
  183. <thead>
  184. <tr>
  185. <th width="20"></th>
  186. <th width="12%" class="bottom_border name">Name</th>
  187. <th width="10%" class="bottom_border">Type</th>
  188. <th width="10%" class="bottom_border">Attributes</th>
  189. <th width="10%" class="bottom_border">Default</th>
  190. <th class="last bottom_border">Description</th>
  191. </tr>
  192. </thead>
  193. <tbody>
  194. <tr class="even"><td class="number right_border"><div>1</div></td><td class="name">iPixels</td><td class="type type-param">int</td><td class="attributes"></td><td class="default"></td><td class="description last"><p>Offset from top to caluclate the row number of</p></td></tr>
  195. </tbody>
  196. </table><h5>Returns:</h5><p class="returns"><p>Row index</p></p><h5>Example:</h5>
  197. <div class="example-code">
  198. <pre class="brush: js"> $(document).ready(function() {
  199. $('#example').dataTable( {
  200. "sScrollY": "200px",
  201. "sAjaxSource": "media/dataset/large.txt",
  202. "sDom": "frtiS",
  203. "bDeferRender": true,
  204. "fnInitComplete": function (o) {
  205. // Find what row number is at 500px
  206. alert( o.oScroller.fnPixelsToRow( 500 ) );
  207. }
  208. } );
  209. } );</pre>
  210. </div>
  211. </div>
  212. <dt id="Scroller#fnRowToPixels" class=" even"><a name="fnRowToPixels"></a><a name="fnRowToPixels_details"></a><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a>fnRowToPixels</a></span><span class="type-sig"><span class="signature">(iRow)</span><span class="type-signature"> &rarr; {int}</span></span></span></dt><dd class=" even"><p>Calculate the pixel position from the top of the scrolling container for a given row</p><div class="collapse_details"><dl class="details">
  213. </dl>
  214. <h5>Parameters:</h5>
  215. <table class="params">
  216. <thead>
  217. <tr>
  218. <th width="20"></th>
  219. <th width="12%" class="bottom_border name">Name</th>
  220. <th width="10%" class="bottom_border">Type</th>
  221. <th width="10%" class="bottom_border">Attributes</th>
  222. <th width="10%" class="bottom_border">Default</th>
  223. <th class="last bottom_border">Description</th>
  224. </tr>
  225. </thead>
  226. <tbody>
  227. <tr class="even"><td class="number right_border"><div>1</div></td><td class="name">iRow</td><td class="type type-param">int</td><td class="attributes"></td><td class="default"></td><td class="description last"><p>Row number to calculate the position of</p></td></tr>
  228. </tbody>
  229. </table><h5>Returns:</h5><p class="returns"><p>Pixels</p></p><h5>Example:</h5>
  230. <div class="example-code">
  231. <pre class="brush: js"> $(document).ready(function() {
  232. $('#example').dataTable( {
  233. "sScrollY": "200px",
  234. "sAjaxSource": "media/dataset/large.txt",
  235. "sDom": "frtiS",
  236. "bDeferRender": true,
  237. "fnInitComplete": function (o) {
  238. // Find where row 25 is
  239. alert( o.oScroller.fnRowToPixels( 25 ) );
  240. }
  241. } );
  242. } );</pre>
  243. </div>
  244. </div>
  245. <dt id="Scroller#fnScrollToRow" class=" odd"><a name="fnScrollToRow"></a><a name="fnScrollToRow_details"></a><span class="type-attr"><span class="type-signature"></span></span><span class="type-name"><a>fnScrollToRow</a></span><span class="type-sig"><span class="signature">(iRow, <span class="optional">bAnimate</span>)</span><span class="type-signature"> &rarr; {void}</span></span></span></dt><dd class=" odd"><p>Calculate the row number that will be found at the given pixel position (y-scroll)</p><div class="collapse_details"><dl class="details">
  246. </dl>
  247. <h5>Parameters:</h5>
  248. <table class="params">
  249. <thead>
  250. <tr>
  251. <th width="20"></th>
  252. <th width="12%" class="bottom_border name">Name</th>
  253. <th width="10%" class="bottom_border">Type</th>
  254. <th width="10%" class="bottom_border">Attributes</th>
  255. <th width="10%" class="bottom_border">Default</th>
  256. <th class="last bottom_border">Description</th>
  257. </tr>
  258. </thead>
  259. <tbody>
  260. <tr class="even"><td class="number right_border"><div>1</div></td><td class="name">iRow</td><td class="type type-param">int</td><td class="attributes"></td><td class="default"></td><td class="description last"><p>Row index to scroll to</p></td></tr><tr class="odd"><td class="number right_border"><div>2</div></td><td class="name">bAnimate</td><td class="type type-param">bool</td><td class="attributes">Optional</td><td class="default">true</td><td class="description last"><p>Animate the transision or not</p></td></tr>
  261. </tbody>
  262. </table><h5>Example:</h5>
  263. <div class="example-code">
  264. <pre class="brush: js"> $(document).ready(function() {
  265. $('#example').dataTable( {
  266. "sScrollY": "200px",
  267. "sAjaxSource": "media/dataset/large.txt",
  268. "sDom": "frtiS",
  269. "bDeferRender": true,
  270. "fnInitComplete": function (o) {
  271. // Immediately scroll to row 1000
  272. o.oScroller.fnScrollToRow( 1000 );
  273. }
  274. } );
  275. // Sometime later on use the following to scroll to row 500...
  276. var oSettings = $('#example').dataTable().fnSettings();
  277. oSettings.oScroller.fnScrollToRow( 500 );
  278. } );</pre>
  279. </div>
  280. </div>
  281. </dd>
  282. </div>
  283. </div>
  284. </div>
  285. <div class="fw_footer">
  286. Scroller: Copyright 2011-2012 Allan Jardine, all rights reserved<br>
  287. Documentation generated by <a href="https://github.com/micmath/JSDoc">JSDoc 3</a> on
  288. 23th Sep 2012 - 14:28
  289. with the <a href="http://datatables.net/">DataTables</a> template.
  290. </div>
  291. </body>
  292. </html>