PageRenderTime 56ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 1ms

/public/theme/source_admin_v1.2.1/admin/angular/template_content/assets/plugins/DataTables/examples/server_side/select_rows.html

https://gitlab.com/metahuman247/business
HTML | 326 lines | 284 code | 42 blank | 0 comment | 0 complexity | 0305c802b424d8681ed70471721b881b MD5 | raw file
  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>DataTables example - Row selection</title>
  8. <link rel="stylesheet" type="text/css" href="../../media/css/jquery.dataTables.css">
  9. <link rel="stylesheet" type="text/css" href="../resources/syntax/shCore.css">
  10. <link rel="stylesheet" type="text/css" href="../resources/demo.css">
  11. <style type="text/css" class="init">
  12. </style>
  13. <script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
  14. <script type="text/javascript" language="javascript" src="../../media/js/jquery.dataTables.js"></script>
  15. <script type="text/javascript" language="javascript" src="../resources/syntax/shCore.js"></script>
  16. <script type="text/javascript" language="javascript" src="../resources/demo.js"></script>
  17. <script type="text/javascript" language="javascript" class="init">
  18. $(document).ready(function() {
  19. var selected = [];
  20. $("#example").DataTable({
  21. "processing": true,
  22. "serverSide": true,
  23. "ajax": "scripts/ids-arrays.php",
  24. "rowCallback": function( row, data ) {
  25. if ( $.inArray(data.DT_RowId, selected) !== -1 ) {
  26. $(row).addClass('selected');
  27. }
  28. }
  29. });
  30. $('#example tbody').on('click', 'tr', function () {
  31. var id = this.id;
  32. var index = $.inArray(id, selected);
  33. if ( index === -1 ) {
  34. selected.push( id );
  35. } else {
  36. selected.splice( index, 1 );
  37. }
  38. $(this).toggleClass('selected');
  39. } );
  40. } );
  41. </script>
  42. </head>
  43. <body class="dt-example">
  44. <div class="container">
  45. <section>
  46. <h1>DataTables example <span>Row selection</span></h1>
  47. <div class="info">
  48. <p>When you want to have user selectable rows in DataTables, it is relatively trivial when using DOM based data - but when using server-side processing, DataTables
  49. doesn't retain DOM row elements over pages / filtering etc. As such, you will need to keep a track of which rows a user as selected and mark them as selected on
  50. each draw.</p>
  51. <p>This is shown in this demo, which uses a unique ID assigned to the TR element (this is done automatically through the use of the <code>DT_RowId</code> special
  52. property returned as part of the object given by the server for each row) to track which rows are selected and reselect them is appropriate on a draw.</p>
  53. <p>If you are looking for a more complete and easier to use row selection option, check out the <a href="https://datatables.net/extras/select">Select extension</a>
  54. provides an API that is fully integrated with DataTables for selecting rows and acting upon those selected rows.</p>
  55. </div>
  56. <table id="example" class="display" cellspacing="0" width="100%">
  57. <thead>
  58. <tr>
  59. <th>First name</th>
  60. <th>Last name</th>
  61. <th>Position</th>
  62. <th>Office</th>
  63. <th>Start date</th>
  64. <th>Salary</th>
  65. </tr>
  66. </thead>
  67. <tfoot>
  68. <tr>
  69. <th>First name</th>
  70. <th>Last name</th>
  71. <th>Position</th>
  72. <th>Office</th>
  73. <th>Start date</th>
  74. <th>Salary</th>
  75. </tr>
  76. </tfoot>
  77. </table>
  78. <ul class="tabs">
  79. <li class="active">Javascript</li>
  80. <li>HTML</li>
  81. <li>CSS</li>
  82. <li>Ajax</li>
  83. <li>Server-side script</li>
  84. </ul>
  85. <div class="tabs">
  86. <div class="js">
  87. <p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
  88. var selected = [];
  89. $(&quot;#example&quot;).DataTable({
  90. &quot;processing&quot;: true,
  91. &quot;serverSide&quot;: true,
  92. &quot;ajax&quot;: &quot;scripts/ids-arrays.php&quot;,
  93. &quot;rowCallback&quot;: function( row, data ) {
  94. if ( $.inArray(data.DT_RowId, selected) !== -1 ) {
  95. $(row).addClass('selected');
  96. }
  97. }
  98. });
  99. $('#example tbody').on('click', 'tr', function () {
  100. var id = this.id;
  101. var index = $.inArray(id, selected);
  102. if ( index === -1 ) {
  103. selected.push( id );
  104. } else {
  105. selected.splice( index, 1 );
  106. }
  107. $(this).toggleClass('selected');
  108. } );
  109. } );</code>
  110. <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
  111. <ul>
  112. <li><a href="//code.jquery.com/jquery-1.11.3.min.js">//code.jquery.com/jquery-1.11.3.min.js</a></li>
  113. <li><a href="../../media/js/jquery.dataTables.js">../../media/js/jquery.dataTables.js</a></li>
  114. </ul>
  115. </div>
  116. <div class="table">
  117. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
  118. </div>
  119. <div class="css">
  120. <div>
  121. <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
  122. additional CSS used is shown below:</p><code class="multiline language-css"></code>
  123. </div>
  124. <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
  125. <ul>
  126. <li><a href="../../media/css/jquery.dataTables.css">../../media/css/jquery.dataTables.css</a></li>
  127. </ul>
  128. </div>
  129. <div class="ajax">
  130. <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
  131. loaded.</p>
  132. </div>
  133. <div class="php">
  134. <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
  135. processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
  136. documentation</a>.</p>
  137. </div>
  138. </div>
  139. </section>
  140. </div>
  141. <section>
  142. <div class="footer">
  143. <div class="gradient"></div>
  144. <div class="liner">
  145. <h2>Other examples</h2>
  146. <div class="toc">
  147. <div class="toc-group">
  148. <h3><a href="../basic_init/index.html">Basic initialisation</a></h3>
  149. <ul class="toc">
  150. <li><a href="../basic_init/zero_configuration.html">Zero configuration</a></li>
  151. <li><a href="../basic_init/filter_only.html">Feature enable / disable</a></li>
  152. <li><a href="../basic_init/table_sorting.html">Default ordering (sorting)</a></li>
  153. <li><a href="../basic_init/multi_col_sort.html">Multi-column ordering</a></li>
  154. <li><a href="../basic_init/multiple_tables.html">Multiple tables</a></li>
  155. <li><a href="../basic_init/hidden_columns.html">Hidden columns</a></li>
  156. <li><a href="../basic_init/complex_header.html">Complex headers (rowspan and colspan)</a></li>
  157. <li><a href="../basic_init/dom.html">DOM positioning</a></li>
  158. <li><a href="../basic_init/flexible_width.html">Flexible table width</a></li>
  159. <li><a href="../basic_init/state_save.html">State saving</a></li>
  160. <li><a href="../basic_init/alt_pagination.html">Alternative pagination</a></li>
  161. <li><a href="../basic_init/scroll_y.html">Scroll - vertical</a></li>
  162. <li><a href="../basic_init/scroll_y_dynamic.html">Scroll - vertical, dynamic height</a></li>
  163. <li><a href="../basic_init/scroll_x.html">Scroll - horizontal</a></li>
  164. <li><a href="../basic_init/scroll_xy.html">Scroll - horizontal and vertical</a></li>
  165. <li><a href="../basic_init/comma-decimal.html">Language - Comma decimal place</a></li>
  166. <li><a href="../basic_init/language.html">Language options</a></li>
  167. </ul>
  168. </div>
  169. <div class="toc-group">
  170. <h3><a href="../advanced_init/index.html">Advanced initialisation</a></h3>
  171. <ul class="toc">
  172. <li><a href="../advanced_init/events_live.html">DOM / jQuery events</a></li>
  173. <li><a href="../advanced_init/dt_events.html">DataTables events</a></li>
  174. <li><a href="../advanced_init/column_render.html">Column rendering</a></li>
  175. <li><a href="../advanced_init/length_menu.html">Page length options</a></li>
  176. <li><a href="../advanced_init/dom_multiple_elements.html">Multiple table control elements</a></li>
  177. <li><a href="../advanced_init/complex_header.html">Complex headers with column visibility</a></li>
  178. <li><a href="../advanced_init/object_dom_read.html">Read HTML to data objects</a></li>
  179. <li><a href="../advanced_init/html5-data-attributes.html">HTML5 data-* attributes - cell data</a></li>
  180. <li><a href="../advanced_init/html5-data-options.html">HTML5 data-* attributes - table options</a></li>
  181. <li><a href="../advanced_init/language_file.html">Language file</a></li>
  182. <li><a href="../advanced_init/defaults.html">Setting defaults</a></li>
  183. <li><a href="../advanced_init/row_callback.html">Row created callback</a></li>
  184. <li><a href="../advanced_init/row_grouping.html">Row grouping</a></li>
  185. <li><a href="../advanced_init/footer_callback.html">Footer callback</a></li>
  186. <li><a href="../advanced_init/dom_toolbar.html">Custom toolbar elements</a></li>
  187. <li><a href="../advanced_init/sort_direction_control.html">Order direction sequence control</a></li>
  188. </ul>
  189. </div>
  190. <div class="toc-group">
  191. <h3><a href="../styling/index.html">Styling</a></h3>
  192. <ul class="toc">
  193. <li><a href="../styling/display.html">Base style</a></li>
  194. <li><a href="../styling/no-classes.html">Base style - no styling classes</a></li>
  195. <li><a href="../styling/cell-border.html">Base style - cell borders</a></li>
  196. <li><a href="../styling/compact.html">Base style - compact</a></li>
  197. <li><a href="../styling/hover.html">Base style - hover</a></li>
  198. <li><a href="../styling/order-column.html">Base style - order-column</a></li>
  199. <li><a href="../styling/row-border.html">Base style - row borders</a></li>
  200. <li><a href="../styling/stripe.html">Base style - stripe</a></li>
  201. <li><a href="../styling/bootstrap.html">Bootstrap</a></li>
  202. <li><a href="../styling/foundation.html">Foundation</a></li>
  203. <li><a href="../styling/jqueryUI.html">jQuery UI ThemeRoller</a></li>
  204. </ul>
  205. </div>
  206. <div class="toc-group">
  207. <h3><a href="../data_sources/index.html">Data sources</a></h3>
  208. <ul class="toc">
  209. <li><a href="../data_sources/dom.html">HTML (DOM) sourced data</a></li>
  210. <li><a href="../data_sources/ajax.html">Ajax sourced data</a></li>
  211. <li><a href="../data_sources/js_array.html">Javascript sourced data</a></li>
  212. <li><a href="../data_sources/server_side.html">Server-side processing</a></li>
  213. </ul>
  214. </div>
  215. <div class="toc-group">
  216. <h3><a href="../api/index.html">API</a></h3>
  217. <ul class="toc">
  218. <li><a href="../api/add_row.html">Add rows</a></li>
  219. <li><a href="../api/multi_filter.html">Individual column searching (text inputs)</a></li>
  220. <li><a href="../api/multi_filter_select.html">Individual column searching (select inputs)</a></li>
  221. <li><a href="../api/highlight.html">Highlighting rows and columns</a></li>
  222. <li><a href="../api/row_details.html">Child rows (show extra / detailed information)</a></li>
  223. <li><a href="../api/select_row.html">Row selection (multiple rows)</a></li>
  224. <li><a href="../api/select_single_row.html">Row selection and deletion (single row)</a></li>
  225. <li><a href="../api/form.html">Form inputs</a></li>
  226. <li><a href="../api/counter_columns.html">Index column</a></li>
  227. <li><a href="../api/show_hide.html">Show / hide columns dynamically</a></li>
  228. <li><a href="../api/api_in_init.html">Using API in callbacks</a></li>
  229. <li><a href="../api/tabs_and_scrolling.html">Scrolling and Bootstrap tabs</a></li>
  230. <li><a href="../api/regex.html">Search API (regular expressions)</a></li>
  231. </ul>
  232. </div>
  233. <div class="toc-group">
  234. <h3><a href="../ajax/index.html">Ajax</a></h3>
  235. <ul class="toc">
  236. <li><a href="../ajax/simple.html">Ajax data source (arrays)</a></li>
  237. <li><a href="../ajax/objects.html">Ajax data source (objects)</a></li>
  238. <li><a href="../ajax/deep.html">Nested object data (objects)</a></li>
  239. <li><a href="../ajax/objects_subarrays.html">Nested object data (arrays)</a></li>
  240. <li><a href="../ajax/orthogonal-data.html">Orthogonal data</a></li>
  241. <li><a href="../ajax/null_data_source.html">Generated content for a column</a></li>
  242. <li><a href="../ajax/custom_data_property.html">Custom data source property</a></li>
  243. <li><a href="../ajax/custom_data_flat.html">Flat array data source</a></li>
  244. <li><a href="../ajax/defer_render.html">Deferred rendering for speed</a></li>
  245. </ul>
  246. </div>
  247. <div class="toc-group">
  248. <h3><a href="./index.html">Server-side</a></h3>
  249. <ul class="toc active">
  250. <li><a href="./simple.html">Server-side processing</a></li>
  251. <li><a href="./custom_vars.html">Custom HTTP variables</a></li>
  252. <li><a href="./post.html">POST data</a></li>
  253. <li><a href="./ids.html">Automatic addition of row ID attributes</a></li>
  254. <li><a href="./object_data.html">Object data source</a></li>
  255. <li><a href="./row_details.html">Row details</a></li>
  256. <li class="active"><a href="./select_rows.html">Row selection</a></li>
  257. <li><a href="./jsonp.html">JSONP data source for remote domains</a></li>
  258. <li><a href="./defer_loading.html">Deferred loading of data</a></li>
  259. <li><a href="./pipeline.html">Pipelining data to reduce Ajax calls for paging</a></li>
  260. </ul>
  261. </div>
  262. <div class="toc-group">
  263. <h3><a href="../plug-ins/index.html">Plug-ins</a></h3>
  264. <ul class="toc">
  265. <li><a href="../plug-ins/api.html">API plug-in methods</a></li>
  266. <li><a href="../plug-ins/sorting_auto.html">Ordering plug-ins (with type detection)</a></li>
  267. <li><a href="../plug-ins/sorting_manual.html">Ordering plug-ins (no type detection)</a></li>
  268. <li><a href="../plug-ins/range_filtering.html">Custom filtering - range search</a></li>
  269. <li><a href="../plug-ins/dom_sort.html">Live DOM ordering</a></li>
  270. </ul>
  271. </div>
  272. </div>
  273. <div class="epilogue">
  274. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
  275. Additionally, there are a wide range of <a href="http://www.datatables.net/extensions">extensions</a> and <a href=
  276. "http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of DataTables.</p>
  277. <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2015<br>
  278. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  279. </div>
  280. </div>
  281. </div>
  282. </section>
  283. </body>
  284. </html>