server-side-processing.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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>FixedColumns example - Server-side processing</title>
  8. <link rel="stylesheet" type="text/css" href="../../../../media/css/jquery.dataTables.css">
  9. <link rel="stylesheet" type="text/css" href="../../css/fixedColumns.dataTables.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. /* Ensure that the demo table scrolls */
  14. th, td { white-space: nowrap; }
  15. div.dataTables_wrapper {
  16. width: 600px;
  17. margin: 0 auto;
  18. }
  19. /* Lots of padding for the cells as SSP has limited data in the demo */
  20. th,
  21. td {
  22. padding-left: 40px !important;
  23. padding-right: 40px !important;
  24. }
  25. </style>
  26. <script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.3.min.js">
  27. </script>
  28. <script type="text/javascript" language="javascript" src="../../../../media/js/jquery.dataTables.js">
  29. </script>
  30. <script type="text/javascript" language="javascript" src="../../js/dataTables.fixedColumns.js">
  31. </script>
  32. <script type="text/javascript" language="javascript" src="../../../../examples/resources/syntax/shCore.js">
  33. </script>
  34. <script type="text/javascript" language="javascript" src="../../../../examples/resources/demo.js">
  35. </script>
  36. <script type="text/javascript" language="javascript" class="init">
  37. $(document).ready(function() {
  38. var table = $('#example').DataTable( {
  39. scrollY: "300px",
  40. scrollX: true,
  41. scrollCollapse: true,
  42. ajax: "../../../../examples/server_side/scripts/server_processing.php",
  43. serverSide: true,
  44. fixedColumns: true
  45. } );
  46. } );
  47. </script>
  48. </head>
  49. <body class="dt-example">
  50. <div class="container">
  51. <section>
  52. <h1>FixedColumns example <span>Server-side processing</span></h1>
  53. <div class="info">
  54. <p>This example shows how FixedColumns can be used with server-side processing in DataTables to cope with very large tables. No special considerations are
  55. required, just initialise FixedColumns as you normally would!</p>
  56. <p>Note that the table width is constrained in this example to allow scrolling to occur as the server-side processing data set has a limited number of columns in
  57. this demo!</p>
  58. </div>
  59. <table id="example" class="stripe row-border order-column" cellspacing="0" width="100%">
  60. <thead>
  61. <tr>
  62. <th>Name</th>
  63. <th>Position</th>
  64. <th>Office</th>
  65. <th>Extn.</th>
  66. <th>Start date</th>
  67. <th>Salary</th>
  68. </tr>
  69. </thead>
  70. <tfoot>
  71. <tr>
  72. <th>Name</th>
  73. <th>Position</th>
  74. <th>Office</th>
  75. <th>Extn.</th>
  76. <th>Start date</th>
  77. <th>Salary</th>
  78. </tr>
  79. </tfoot>
  80. </table>
  81. <ul class="tabs">
  82. <li class="active">Javascript</li>
  83. <li>HTML</li>
  84. <li>CSS</li>
  85. <li>Ajax</li>
  86. <li>Server-side script</li>
  87. </ul>
  88. <div class="tabs">
  89. <div class="js">
  90. <p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
  91. var table = $('#example').DataTable( {
  92. scrollY: &quot;300px&quot;,
  93. scrollX: true,
  94. scrollCollapse: true,
  95. ajax: &quot;../../../../examples/server_side/scripts/server_processing.php&quot;,
  96. serverSide: true,
  97. fixedColumns: true
  98. } );
  99. } );</code>
  100. <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
  101. <ul>
  102. <li>
  103. <a href="//code.jquery.com/jquery-1.11.3.min.js">//code.jquery.com/jquery-1.11.3.min.js</a>
  104. </li>
  105. <li>
  106. <a href="../../../../media/js/jquery.dataTables.js">../../../../media/js/jquery.dataTables.js</a>
  107. </li>
  108. <li>
  109. <a href="../../js/dataTables.fixedColumns.js">../../js/dataTables.fixedColumns.js</a>
  110. </li>
  111. </ul>
  112. </div>
  113. <div class="table">
  114. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
  115. </div>
  116. <div class="css">
  117. <div>
  118. <p>This example uses a little bit of additional CSS beyond what is loaded from the library files (below), in order to correctly display the table. The
  119. additional CSS used is shown below:</p><code class="multiline language-css">/* Ensure that the demo table scrolls */
  120. th, td { white-space: nowrap; }
  121. div.dataTables_wrapper {
  122. width: 600px;
  123. margin: 0 auto;
  124. }
  125. /* Lots of padding for the cells as SSP has limited data in the demo */
  126. th,
  127. td {
  128. padding-left: 40px !important;
  129. padding-right: 40px !important;
  130. }</code>
  131. </div>
  132. <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
  133. <ul>
  134. <li>
  135. <a href="../../../../media/css/jquery.dataTables.css">../../../../media/css/jquery.dataTables.css</a>
  136. </li>
  137. <li>
  138. <a href="../../css/fixedColumns.dataTables.css">../../css/fixedColumns.dataTables.css</a>
  139. </li>
  140. </ul>
  141. </div>
  142. <div class="ajax">
  143. <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data will update automatically as any additional data is
  144. loaded.</p>
  145. </div>
  146. <div class="php">
  147. <p>The script used to perform the server-side processing for this table is shown below. Please note that this is just an example script using PHP. Server-side
  148. processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
  149. documentation</a>.</p>
  150. </div>
  151. </div>
  152. </section>
  153. </div>
  154. <section>
  155. <div class="footer">
  156. <div class="gradient"></div>
  157. <div class="liner">
  158. <h2>Other examples</h2>
  159. <div class="toc">
  160. <div class="toc-group">
  161. <h3><a href="../initialisation/index.html">Initialisation</a></h3>
  162. <ul class="toc">
  163. <li>
  164. <a href="../initialisation/left_right_columns.html">Left and right fixed columns</a>
  165. </li>
  166. <li>
  167. <a href="../initialisation/simple.html">Basic initialisation</a>
  168. </li>
  169. <li>
  170. <a href="../initialisation/two_columns.html">Multiple fixed columns</a>
  171. </li>
  172. <li>
  173. <a href="../initialisation/right_column.html">Right column only</a>
  174. </li>
  175. <li>
  176. <a href="../initialisation/colvis.html">Column visibility integration</a>
  177. </li>
  178. <li>
  179. <a href="../initialisation/server-side-processing.html">Server-side processing</a>
  180. </li>
  181. <li>
  182. <a href="../initialisation/css_size.html">CSS row sizing</a>
  183. </li>
  184. <li>
  185. <a href="../initialisation/size_fixed.html">Assigned column width</a>
  186. </li>
  187. <li>
  188. <a href="../initialisation/size_fluid.html">Fluid column width</a>
  189. </li>
  190. <li>
  191. <a href="../initialisation/index_column.html">Index column</a>
  192. </li>
  193. </ul>
  194. </div>
  195. <div class="toc-group">
  196. <h3><a href="./index.html">Styling</a></h3>
  197. <ul class="toc active">
  198. <li>
  199. <a href="./rowspan.html">Complex headers</a>
  200. </li>
  201. <li>
  202. <a href="./colvis.html">Column visibility integration</a>
  203. </li>
  204. <li class="active">
  205. <a href="./server-side-processing.html">Server-side processing</a>
  206. </li>
  207. <li>
  208. <a href="./col_filter.html">Individual column filtering</a>
  209. </li>
  210. <li>
  211. <a href="./bootstrap.html">Bootstrap</a>
  212. </li>
  213. <li>
  214. <a href="./foundation.html">Foundation</a>
  215. </li>
  216. <li>
  217. <a href="./jqueryui.html">jQuery UI</a>
  218. </li>
  219. </ul>
  220. </div>
  221. </div>
  222. <div class="epilogue">
  223. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
  224. Additionally, there are a wide range of <a href="http://www.datatables.net/extensions">extensions</a> and <a href=
  225. "http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of DataTables.</p>
  226. <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2015<br>
  227. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  228. </div>
  229. </div>
  230. </div>
  231. </section>
  232. </body>
  233. </html>