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">
8 <title>TableTools example - Row selection - row selector on specific cells</title>
9 <link rel="stylesheet" type="text/css" href="../../../media/css/jquery.dataTables.css">
10 <link rel="stylesheet" type="text/css" href="../css/dataTables.tableTools.css">
11 <link rel="stylesheet" type="text/css" href="//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">
20 tr td:first-child:before {
21 content: "\f096"; /* fa-square-o */
22 font-family: FontAwesome;
25 tr.selected td:first-child:before {
26 content: "\f046"; /* fa-check-square-o */
30 <script type="text/javascript" language="javascript" src="../../../media/js/jquery.js"></script>
31 <script type="text/javascript" language="javascript" src="../../../media/js/jquery.dataTables.js"></script>
32 <script type="text/javascript" language="javascript" src="../js/dataTables.tableTools.js"></script>
33 <script type="text/javascript" language="javascript" src="../../../examples/resources/syntax/shCore.js"></script>
34 <script type="text/javascript" language="javascript" src="../../../examples/resources/demo.js"></script>
35 <script type="text/javascript" language="javascript" class="init">
39 $(document).ready(function() {
40 $('#example').DataTable( {
41 ajax: "../../../examples/ajax/data/objects.txt",
43 { data: null, defaultContent: '', orderable: false },
48 { data: 'start_date' },
52 dom: 'T<"clear">lfrtip',
55 sRowSelector: 'td:first-child',
56 aButtons: [ 'select_all', 'select_none' ]
65 <body class="dt-example">
66 <div class="container">
68 <h1>TableTools example <span>Row selection - row selector on specific cells</span></h1>
71 <p>By default, TableTools' row selector option will register a row selection click on any part of the row. Although this is often desirable, you might wish at
72 times to limit the row selection to just a single column, or other elements in the row. This might be useful, for example, with <a href=
73 "//editor.datatables.net">Editor's</a> inline editing, so you don't select the row on click of a cell that is to be edited.</p>
75 <p>The <code>sRowSelector</code> method provides this ability, allowing a custom jQuery selector to be passed in. TableTools will use the parent row of any element
76 that is selected by the end user.</p>
78 <p>In this case, the row selector is attached to the cells in the first column of the table, and <a href="http://fortawesome.github.io/Font-Awesome">Font
79 Awesome</a> is used to display a checkbox indicating the selection state of the row, in addition to the row background colouring.</p>
82 <table id="example" class="display" cellspacing="0" width="100%">
98 <li class="active">Javascript</li>
102 <li>Server-side script</li>
107 <p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
108 $('#example').DataTable( {
109 ajax: "../../../examples/ajax/data/objects.txt",
111 { data: null, defaultContent: '', orderable: false },
113 { data: 'position' },
116 { data: 'start_date' },
120 dom: 'T<"clear">lfrtip',
123 sRowSelector: 'td:first-child',
124 aButtons: [ 'select_all', 'select_none' ]
129 <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
132 <li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
133 <li><a href="../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
134 <li><a href="../js/dataTables.tableTools.js">../js/dataTables.tableTools.js</a></li>
139 <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
144 <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
145 additional CSS used is shown below:</p><code class="multiline language-css">tr td:first-child {
149 tr td:first-child:before {
150 content: "\f096"; /* fa-square-o */
151 font-family: FontAwesome;
154 tr.selected td:first-child:before {
155 content: "\f046"; /* fa-check-square-o */
159 <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
162 <li><a href="../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
163 <li><a href="../css/dataTables.tableTools.css">../css/dataTables.tableTools.css</a></li>
165 "//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>
170 <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
175 <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
176 processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
177 documentation</a>.</p>
185 <div class="gradient"></div>
188 <h2>Other examples</h2>
191 <div class="toc-group">
192 <h3><a href="./index.html">Examples</a></h3>
193 <ul class="toc active">
194 <li><a href="./simple.html">Basic initialisation</a></li>
195 <li><a href="./swf_path.html">Setting the SWF path</a></li>
196 <li><a href="./new_init.html">Initialisation with `new`</a></li>
197 <li><a href="./defaults.html">Defaults</a></li>
198 <li><a href="./select_single.html">Row selection - single row select</a></li>
199 <li><a href="./select_multi.html">Row selection - multi-row select</a></li>
200 <li><a href="./select_os.html">Row selection - operating system style</a></li>
201 <li class="active"><a href="./select_column.html">Row selection - row selector on specific cells</a></li>
202 <li><a href="./multiple_tables.html">Multiple tables</a></li>
203 <li><a href="./multi_instance.html">Multiple toolbars</a></li>
204 <li><a href="./collection.html">Button collections</a></li>
205 <li><a href="./plug-in.html">Plug-in button types</a></li>
206 <li><a href="./button_text.html">Custom button text</a></li>
207 <li><a href="./alter_buttons.html">Button arrangement</a></li>
208 <li><a href="./ajax.html">Ajax loaded data</a></li>
209 <li><a href="./pdf_message.html">PDF message</a></li>
210 <li><a href="./bootstrap.html">Bootstrap styling</a></li>
211 <li><a href="./jqueryui.html">jQuery UI styling</a></li>
216 <div class="epilogue">
217 <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
218 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>
219 which extend the capabilities of DataTables.</p>
221 <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2015<br>
222 DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>