select_column.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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>TableTools example - Row selection - row selector on specific cells</title>
  8. <link rel="stylesheet" type="text/css" href="../../../media/css/jquery.dataTables.css">
  9. <link rel="stylesheet" type="text/css" href="../css/dataTables.tableTools.css">
  10. <link rel="stylesheet" type="text/css" href=
  11. "//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css">
  12. <link rel="stylesheet" type="text/css" href="../../../examples/resources/syntax/shCore.css">
  13. <link rel="stylesheet" type="text/css" href="../../../examples/resources/demo.css">
  14. <style type="text/css" class="init">
  15. tr td:first-child {
  16. text-align: center;
  17. }
  18. tr td:first-child:before {
  19. content: "\f096"; /* fa-square-o */
  20. font-family: FontAwesome;
  21. }
  22. tr.selected td:first-child:before {
  23. content: "\f046"; /* fa-check-square-o */
  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.tableTools.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. $('#example').DataTable( {
  34. ajax: "../../../examples/ajax/data/objects.txt",
  35. columns: [
  36. { data: null, defaultContent: '', orderable: false },
  37. { data: 'name' },
  38. { data: 'position' },
  39. { data: 'office' },
  40. { data: 'extn' },
  41. { data: 'start_date' },
  42. { data: 'salary' }
  43. ],
  44. order: [ 1, 'asc' ],
  45. dom: 'T<"clear">lfrtip',
  46. tableTools: {
  47. sRowSelect: 'os',
  48. sRowSelector: 'td:first-child',
  49. aButtons: [ 'select_all', 'select_none' ]
  50. }
  51. } );
  52. } );
  53. </script>
  54. </head>
  55. <body class="dt-example">
  56. <div class="container">
  57. <section>
  58. <h1>TableTools example <span>Row selection - row selector on specific cells</span></h1>
  59. <div class="info">
  60. <p>By default, TableTools' row selector option will register a row selection click on any part of the
  61. row. Although this is often desirable, you might wish at times to limit the row selection to just a
  62. single column, or other elements in the row. This might be useful, for example, with <a href=
  63. "//editor.datatables.net">Editor's</a> inline editing, so you don't select the row on click of a cell
  64. that is to be edited.</p>
  65. <p>The <code>sRowSelector</code> method provides this ability, allowing a custom jQuery selector to be
  66. passed in. TableTools will use the parent row of any element that is selected by the end user.</p>
  67. <p>In this case, the row selector is attached to the cells in the first column of the table, and
  68. <a href="http://fortawesome.github.io/Font-Awesome">Font Awesome</a> is used to display a checkbox
  69. indicating the selection state of the row, in addition to the row background colouring.</p>
  70. </div>
  71. <table id="example" class="display" cellspacing="0" width="100%">
  72. <thead>
  73. <tr>
  74. <th>
  75. <th>Name</th>
  76. <th>Position</th>
  77. <th>Office</th>
  78. <th>Age</th>
  79. <th>Start date</th>
  80. <th>Salary</th>
  81. </tr>
  82. </thead>
  83. </table>
  84. <ul class="tabs">
  85. <li class="active">Javascript</li>
  86. <li>HTML</li>
  87. <li>CSS</li>
  88. <li>Ajax</li>
  89. <li>Server-side script</li>
  90. </ul>
  91. <div class="tabs">
  92. <div class="js">
  93. <p>The Javascript shown below is used to initialise the table shown in this
  94. example:</p><code class="multiline brush: js;">$(document).ready(function() {
  95. $('#example').DataTable( {
  96. ajax: &quot;../../../examples/ajax/data/objects.txt&quot;,
  97. columns: [
  98. { data: null, defaultContent: '', orderable: false },
  99. { data: 'name' },
  100. { data: 'position' },
  101. { data: 'office' },
  102. { data: 'extn' },
  103. { data: 'start_date' },
  104. { data: 'salary' }
  105. ],
  106. order: [ 1, 'asc' ],
  107. dom: 'T&lt;&quot;clear&quot;&gt;lfrtip',
  108. tableTools: {
  109. sRowSelect: 'os',
  110. sRowSelector: 'td:first-child',
  111. aButtons: [ 'select_all', 'select_none' ]
  112. }
  113. } );
  114. } );</code>
  115. <p>In addition to the above code, the following Javascript library files are loaded for use in this
  116. example:</p>
  117. <ul>
  118. <li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
  119. <li><a href=
  120. "../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
  121. <li><a href="../js/dataTables.tableTools.js">../js/dataTables.tableTools.js</a></li>
  122. </ul>
  123. </div>
  124. <div class="table">
  125. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by
  126. DataTables:</p>
  127. </div>
  128. <div class="css">
  129. <div>
  130. <p>This example uses a little bit of additional CSS beyond what is loaded from the library
  131. files (below), in order to correctly display the table. The additional CSS used is shown
  132. below:</p><code class="multiline brush: js;">tr td:first-child {
  133. text-align: center;
  134. }
  135. tr td:first-child:before {
  136. content: &quot;\f096&quot;; /* fa-square-o */
  137. font-family: FontAwesome;
  138. }
  139. tr.selected td:first-child:before {
  140. content: &quot;\f046&quot;; /* fa-check-square-o */
  141. }</code>
  142. </div>
  143. <p>The following CSS library files are loaded for use in this example to provide the styling of the
  144. table:</p>
  145. <ul>
  146. <li><a href=
  147. "../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
  148. <li><a href="../css/dataTables.tableTools.css">../css/dataTables.tableTools.css</a></li>
  149. <li><a href=
  150. "//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css">//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.3/css/font-awesome.css</a></li>
  151. </ul>
  152. </div>
  153. <div class="ajax">
  154. <p>This table loads data by Ajax. The latest data that has been loaded is shown below. This data
  155. will update automatically as any additional data is loaded.</p>
  156. </div>
  157. <div class="php">
  158. <p>The script used to perform the server-side processing for this table is shown below. Please note
  159. that this is just an example script using PHP. Server-side processing scripts can be written in any
  160. language, using <a href="//datatables.net/manual/server-side">the protocol described in the
  161. DataTables documentation</a>.</p>
  162. </div>
  163. </div>
  164. </section>
  165. </div>
  166. <section>
  167. <div class="footer">
  168. <div class="gradient"></div>
  169. <div class="liner">
  170. <h2>Other examples</h2>
  171. <div class="toc">
  172. <div class="toc-group">
  173. <h3><a href="./index.html">Examples</a></h3>
  174. <ul class="toc active">
  175. <li><a href="./simple.html">Basic initialisation</a></li>
  176. <li><a href="./plug-in.html">Plug-in button types</a></li>
  177. <li><a href="./bootstrap.html">Bootstrap styling</a></li>
  178. <li><a href="./swf_path.html">Setting the SWF path</a></li>
  179. <li><a href="./new_init.html">Initialisation with `new`</a></li>
  180. <li><a href="./defaults.html">Defaults</a></li>
  181. <li><a href="./select_single.html">Row selection - single row select</a></li>
  182. <li><a href="./select_multi.html">Row selection - multi-row select</a></li>
  183. <li><a href="./select_os.html">Row selection - operating system style</a></li>
  184. <li class="active"><a href="./select_column.html">Row selection - row selector on specific
  185. cells</a></li>
  186. <li><a href="./multiple_tables.html">Multiple tables</a></li>
  187. <li><a href="./multi_instance.html">Multiple toolbars</a></li>
  188. <li><a href="./collection.html">Button collections</a></li>
  189. <li><a href="./button_text.html">Custom button text</a></li>
  190. <li><a href="./alter_buttons.html">Button arrangement</a></li>
  191. <li><a href="./ajax.html">Ajax loaded data</a></li>
  192. <li><a href="./pdf_message.html">PDF message</a></li>
  193. <li><a href="./jqueryui.html">jQuery UI styling</a></li>
  194. </ul>
  195. </div>
  196. </div>
  197. <div class="epilogue">
  198. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full
  199. information about its API properties and methods.<br>
  200. Additionally, there are a wide range of <a href="http://www.datatables.net/extras">extras</a> and
  201. <a href="http://www.datatables.net/plug-ins">plug-ins</a> which extend the capabilities of
  202. DataTables.</p>
  203. <p class="copyright">DataTables designed and created by <a href=
  204. "http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2014<br>
  205. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  206. </div>
  207. </div>
  208. </div>
  209. </section>
  210. </body>
  211. </html>