server-side-processing.html 7.5 KB

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