server-side-processing.html 7.4 KB

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