row_details.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/media/images/favicon.ico" />
  6. <title>DataTables example</title>
  7. <style type="text/css" title="currentStyle">
  8. @import "../../media/css/demo_page.css";
  9. @import "../../media/css/demo_table.css";
  10. </style>
  11. <script type="text/javascript" language="javascript" src="../../media/js/jquery.js"></script>
  12. <script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
  13. <script type="text/javascript" charset="utf-8">
  14. var oTable;
  15. /* Formating function for row details */
  16. function fnFormatDetails ( nTr )
  17. {
  18. var aData = oTable.fnGetData( nTr );
  19. var sOut = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">';
  20. sOut += '<tr><td>Rendering engine:</td><td>'+aData[2]+' '+aData[5]+'</td></tr>';
  21. sOut += '<tr><td>Link to source:</td><td>Could provide a link here</td></tr>';
  22. sOut += '<tr><td>Extra info:</td><td>And any further details here (images etc)</td></tr>';
  23. sOut += '</table>';
  24. return sOut;
  25. }
  26. $(document).ready(function() {
  27. oTable = $('#example').dataTable( {
  28. "bProcessing": true,
  29. "bServerSide": true,
  30. "sAjaxSource": "scripts/details_col.php",
  31. "aoColumns": [
  32. { "sClass": "center", "bSortable": false },
  33. null,
  34. null,
  35. null,
  36. { "sClass": "center" },
  37. { "sClass": "center" }
  38. ],
  39. "aaSorting": [[1, 'asc']]
  40. } );
  41. $('#example tbody td img').live( 'click', function () {
  42. var nTr = $(this).parents('tr')[0];
  43. if ( oTable.fnIsOpen(nTr) )
  44. {
  45. /* This row is already open - close it */
  46. this.src = "../examples_support/details_open.png";
  47. oTable.fnClose( nTr );
  48. }
  49. else
  50. {
  51. /* Open this row */
  52. this.src = "../examples_support/details_close.png";
  53. oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
  54. }
  55. } );
  56. } );
  57. </script>
  58. </head>
  59. <body id="dt_example">
  60. <div id="container">
  61. <div class="full_width big">
  62. DataTables server-side processing example with hidden row information
  63. </div>
  64. <h1>Preamble</h1>
  65. <p>This example shows how you might modify the client-side show/hide details rows example for use with DataTables server-side processing option.</p>
  66. <h1>Live example</h1>
  67. <div id="dynamic">
  68. <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
  69. <thead>
  70. <tr>
  71. <th width="4%"></th>
  72. <th width="25%">Rendering engine</th>
  73. <th width="20%">Browser</th>
  74. <th width="25%">Platform(s)</th>
  75. <th width="16%">Engine version</th>
  76. <th width="10%">CSS grade</th>
  77. </tr>
  78. </thead>
  79. <tbody>
  80. <tr>
  81. <td colspan="5" class="dataTables_empty">Loading data from server</td>
  82. </tr>
  83. </tbody>
  84. <tfoot>
  85. <tr>
  86. <th></th>
  87. <th>Rendering engine</th>
  88. <th>Browser</th>
  89. <th>Platform(s)</th>
  90. <th>Engine version</th>
  91. <th>CSS grade</th>
  92. </tr>
  93. </tfoot>
  94. </table>
  95. </div>
  96. <div class="spacer"></div>
  97. <h1>Initialisation code</h1>
  98. <pre class="brush: js;">var oTable;
  99. /* Formating function for row details */
  100. function fnFormatDetails ( nTr )
  101. {
  102. var aData = oTable.fnGetData( nTr );
  103. var sOut = '&lt;table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;"&gt;';
  104. sOut += '&lt;tr&gt;&lt;td&gt;Rendering engine:&lt;/td&gt;&lt;td&gt;'+aData[2]+' '+aData[5]+'&lt;/td&gt;&lt;/tr&gt;';
  105. sOut += '&lt;tr&gt;&lt;td&gt;Link to source:&lt;/td&gt;&lt;td&gt;Could provide a link here&lt;/td&gt;&lt;/tr&gt;';
  106. sOut += '&lt;tr&gt;&lt;td&gt;Extra info:&lt;/td&gt;&lt;td&gt;And any further details here (images etc)&lt;/td&gt;&lt;/tr&gt;';
  107. sOut += '&lt;/table&gt;';
  108. return sOut;
  109. }
  110. $(document).ready(function() {
  111. oTable = $('#example').dataTable( {
  112. "bProcessing": true,
  113. "bServerSide": true,
  114. "sAjaxSource": "scripts/details_col.php",
  115. "aoColumns": [
  116. { "sClass": "center", "bSortable": false },
  117. null,
  118. null,
  119. null,
  120. { "sClass": "center" },
  121. { "sClass": "center" }
  122. ],
  123. "aaSorting": [[1, 'asc']]
  124. } );
  125. $('#example tbody td img').live( 'click', function () {
  126. var nTr = $(this).parents('tr')[0];
  127. if ( oTable.fnIsOpen(nTr) )
  128. {
  129. /* This row is already open - close it */
  130. this.src = "../examples_support/details_open.png";
  131. oTable.fnClose( nTr );
  132. }
  133. else
  134. {
  135. /* Open this row */
  136. this.src = "../examples_support/details_close.png";
  137. oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
  138. }
  139. } );
  140. } );</pre>
  141. <style type="text/css">
  142. @import "../examples_support/syntax/css/shCore.css";
  143. </style>
  144. <script type="text/javascript" language="javascript" src="../examples_support/syntax/js/shCore.js"></script>
  145. <h1>Server response</h1>
  146. <p>The code below shows the latest JSON data that has been returned from the server in response to the Ajax request made by DataTables. This will update as further requests are made.</p>
  147. <pre id="latest_xhr" class="brush: js;"></pre>
  148. <h1>Other examples</h1>
  149. <div class="demo_links">
  150. <h2>Basic initialisation</h2>
  151. <ul>
  152. <li><a href="../basic_init/zero_config.html">Zero configuration</a></li>
  153. <li><a href="../basic_init/filter_only.html">Feature enablement</a></li>
  154. <li><a href="../basic_init/table_sorting.html">Sorting data</a></li>
  155. <li><a href="../basic_init/multi_col_sort.html">Multi-column sorting</a></li>
  156. <li><a href="../basic_init/multiple_tables.html">Multiple tables</a></li>
  157. <li><a href="../basic_init/hidden_columns.html">Hidden columns</a></li>
  158. <li><a href="../basic_init/complex_header.html">Complex headers - grouping with colspan</a></li>
  159. <li><a href="../basic_init/dom.html">DOM positioning</a></li>
  160. <li><a href="../basic_init/flexible_width.html">Flexible table width</a></li>
  161. <li><a href="../basic_init/state_save.html">State saving</a></li>
  162. <li><a href="../basic_init/alt_pagination.html">Alternative pagination styles</a></li>
  163. <li>Scrolling: <br>
  164. <a href="../basic_init/scroll_x.html">Horizontal</a> /
  165. <a href="../basic_init/scroll_y.html">Vertical</a> /
  166. <a href="../basic_init/scroll_xy.html">Both</a> /
  167. <a href="../basic_init/scroll_y_theme.html">Themed</a> /
  168. <a href="../basic_init/scroll_y_infinite.html">Infinite</a>
  169. </li>
  170. <li><a href="../basic_init/language.html">Change language information (internationalisation)</a></li>
  171. <li><a href="../basic_init/themes.html">ThemeRoller themes (Smoothness)</a></li>
  172. </ul>
  173. <h2>Advanced initialisation</h2>
  174. <ul>
  175. <li>Events: <br>
  176. <a href="../advanced_init/events_live.html">Live events</a> /
  177. <a href="../advanced_init/events_pre_init.html">Pre-init</a> /
  178. <a href="../advanced_init/events_post_init.html">Post-init</a>
  179. </li>
  180. <li><a href="../advanced_init/column_render.html">Column rendering</a></li>
  181. <li><a href="../advanced_init/html_sort.html">Sorting without HTML tags</a></li>
  182. <li><a href="../advanced_init/dom_multiple_elements.html">Multiple table controls (sDom)</a></li>
  183. <li><a href="../advanced_init/length_menu.html">Defining length menu options</a></li>
  184. <li><a href="../advanced_init/complex_header.html">Complex headers and hidden columns</a></li>
  185. <li><a href="../advanced_init/dom_toolbar.html">Custom toolbar (element) around table</a></li>
  186. <li><a href="../advanced_init/highlight.html">Row highlighting with CSS</a></li>
  187. <li><a href="../advanced_init/row_grouping.html">Row grouping</a></li>
  188. <li><a href="../advanced_init/row_callback.html">Row callback</a></li>
  189. <li><a href="../advanced_init/footer_callback.html">Footer callback</a></li>
  190. <li><a href="../advanced_init/sorting_control.html">Control sorting direction of columns</a></li>
  191. <li><a href="../advanced_init/language_file.html">Change language information from a file (internationalisation)</a></li>
  192. <li><a href="../advanced_init/defaults.html">Setting defaults</a></li>
  193. <li><a href="../advanced_init/localstorage.html">State saving with localStorage</a></li>
  194. <li><a href="../advanced_init/dt_events.html">Custom events</a></li>
  195. </ul>
  196. <h2>API</h2>
  197. <ul>
  198. <li><a href="../api/add_row.html">Dynamically add a new row</a></li>
  199. <li><a href="../api/multi_filter.html">Individual column filtering (using "input" elements)</a></li>
  200. <li><a href="../api/multi_filter_select.html">Individual column filtering (using "select" elements)</a></li>
  201. <li><a href="../api/highlight.html">Highlight rows and columns</a></li>
  202. <li><a href="../api/row_details.html">Show and hide details about a particular record</a></li>
  203. <li><a href="../api/select_row.html">User selectable rows (multiple rows)</a></li>
  204. <li><a href="../api/select_single_row.html">User selectable rows (single row) and delete rows</a></li>
  205. <li><a href="../api/editable.html">Editable rows (with jEditable)</a></li>
  206. <li><a href="../api/form.html">Submit form with elements in table</a></li>
  207. <li><a href="../api/counter_column.html">Index column (static number column)</a></li>
  208. <li><a href="../api/show_hide.html">Show and hide columns dynamically</a></li>
  209. <li><a href="../api/api_in_init.html">API function use in initialisation object (callback)</a></li>
  210. <li><a href="../api/tabs_and_scrolling.html">DataTables scrolling and tabs</a></li>
  211. <li><a href="../api/regex.html">Regular expression filtering</a></li>
  212. </ul>
  213. </div>
  214. <div class="demo_links">
  215. <h2>Data sources</h2>
  216. <ul>
  217. <li><a href="../data_sources/dom.html">DOM</a></li>
  218. <li><a href="../data_sources/js_array.html">Javascript array</a></li>
  219. <li><a href="../data_sources/ajax.html">Ajax source</a></li>
  220. <li><a href="../data_sources/server_side.html">Server side processing</a></li>
  221. </ul>
  222. <h2>Server-side processing</h2>
  223. <ul>
  224. <li><a href="../server_side/server_side.html">Obtain server-side data</a></li>
  225. <li><a href="../server_side/custom_vars.html">Add extra HTTP variables</a></li>
  226. <li><a href="../server_side/post.html">Use HTTP POST</a></li>
  227. <li><a href="../server_side/ids.html">Automatic addition of IDs and classes to rows</a></li>
  228. <li><a href="../server_side/object_data.html">Reading table data from objects</a></li>
  229. <li><a href="../server_side/row_details.html">Show and hide details about a particular record</a></li>
  230. <li><a href="../server_side/select_rows.html">User selectable rows (multiple rows)</a></li>
  231. <li><a href="../server_side/jsonp.html">JSONP for a cross domain data source</a></li>
  232. <li><a href="../server_side/editable.html">jEditable integration with DataTables</a></li>
  233. <li><a href="../server_side/defer_loading.html">Deferred loading of Ajax data</a></li>
  234. <li><a href="../server_side/pipeline.html">Pipelining data (reduce Ajax calls for paging)</a></li>
  235. </ul>
  236. <h2>Ajax data source</h2>
  237. <ul>
  238. <li><a href="../ajax/ajax.html">Ajax sourced data (array of arrays)</a></li>
  239. <li><a href="../ajax/objects.html">Ajax sourced data (array of objects)</a></li>
  240. <li><a href="../ajax/defer_render.html">Deferred DOM creation for extra speed</a></li>
  241. <li><a href="../ajax/null_data_source.html">Empty data source columns</a></li>
  242. <li><a href="../ajax/custom_data_property.html">Use a data source other than aaData (the default)</a></li>
  243. <li><a href="../ajax/objects_subarrays.html">Read column data from sub-arrays</a></li>
  244. <li><a href="../ajax/deep.html">Read column data from deeply nested properties</a></li>
  245. </ul>
  246. <h2>Plug-ins</h2>
  247. <ul>
  248. <li><a href="../plug-ins/plugin_api.html">Add custom API functions</a></li>
  249. <li><a href="../plug-ins/sorting_plugin.html">Sorting and automatic type detection</a></li>
  250. <li><a href="../plug-ins/sorting_sType.html">Sorting without automatic type detection</a></li>
  251. <li><a href="../plug-ins/paging_plugin.html">Custom pagination controls</a></li>
  252. <li><a href="../plug-ins/range_filtering.html">Range filtering / custom filtering</a></li>
  253. <li><a href="../plug-ins/dom_sort.html">Live DOM sorting</a></li>
  254. <li><a href="../plug-ins/html_sort.html">Automatic HTML type detection</a></li>
  255. </ul>
  256. </div>
  257. <div id="footer" class="clear" style="text-align:center;">
  258. <p>
  259. Please refer to the <a href="http://www.datatables.net/usage">DataTables documentation</a> for full information about its API properties and methods.<br>
  260. 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> which extend the capabilities of DataTables.
  261. </p>
  262. <span style="font-size:10px;">
  263. DataTables designed and created by <a href="http://www.sprymedia.co.uk">Allan Jardine</a> &copy; 2007-2011<br>
  264. DataTables is dual licensed under the <a href="http://www.datatables.net/license_gpl2">GPL v2 license</a> or a <a href="http://www.datatables.net/license_bsd">BSD (3-point) license</a>.
  265. </span>
  266. </div>
  267. </div>
  268. </body>
  269. </html>