]>
Commit | Line | Data |
---|---|---|
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 | ||
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"> | |
15 | ||
16 | tr td:first-child { | |
17 | text-align: center; | |
18 | } | |
19 | ||
20 | tr td:first-child:before { | |
21 | content: "\f096"; /* fa-square-o */ | |
22 | font-family: FontAwesome; | |
23 | } | |
24 | ||
25 | tr.selected td:first-child:before { | |
26 | content: "\f046"; /* fa-check-square-o */ | |
27 | } | |
28 | ||
29 | </style> | |
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"> | |
36 | ||
37 | ||
38 | ||
39 | $(document).ready(function() { | |
40 | $('#example').DataTable( { | |
41 | ajax: "../../../examples/ajax/data/objects.txt", | |
42 | columns: [ | |
43 | { data: null, defaultContent: '', orderable: false }, | |
44 | { data: 'name' }, | |
45 | { data: 'position' }, | |
46 | { data: 'office' }, | |
47 | { data: 'extn' }, | |
48 | { data: 'start_date' }, | |
49 | { data: 'salary' } | |
50 | ], | |
51 | order: [ 1, 'asc' ], | |
52 | dom: 'T<"clear">lfrtip', | |
53 | tableTools: { | |
54 | sRowSelect: 'os', | |
55 | sRowSelector: 'td:first-child', | |
56 | aButtons: [ 'select_all', 'select_none' ] | |
57 | } | |
58 | } ); | |
59 | } ); | |
60 | ||
61 | ||
62 | </script> | |
63 | </head> | |
64 | ||
65 | <body class="dt-example"> | |
66 | <div class="container"> | |
67 | <section> | |
68 | <h1>TableTools example <span>Row selection - row selector on specific cells</span></h1> | |
69 | ||
70 | <div class="info"> | |
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> | |
74 | ||
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> | |
77 | ||
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> | |
80 | </div> | |
81 | ||
82 | <table id="example" class="display" cellspacing="0" width="100%"> | |
83 | <thead> | |
84 | <tr> | |
85 | <th> | |
86 | ||
87 | <th>Name</th> | |
88 | <th>Position</th> | |
89 | <th>Office</th> | |
90 | <th>Age</th> | |
91 | <th>Start date</th> | |
92 | <th>Salary</th> | |
93 | </tr> | |
94 | </thead> | |
95 | </table> | |
96 | ||
97 | <ul class="tabs"> | |
98 | <li class="active">Javascript</li> | |
99 | <li>HTML</li> | |
100 | <li>CSS</li> | |
101 | <li>Ajax</li> | |
102 | <li>Server-side script</li> | |
103 | </ul> | |
104 | ||
105 | <div class="tabs"> | |
106 | <div class="js"> | |
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", | |
110 | columns: [ | |
111 | { data: null, defaultContent: '', orderable: false }, | |
112 | { data: 'name' }, | |
113 | { data: 'position' }, | |
114 | { data: 'office' }, | |
115 | { data: 'extn' }, | |
116 | { data: 'start_date' }, | |
117 | { data: 'salary' } | |
118 | ], | |
119 | order: [ 1, 'asc' ], | |
120 | dom: 'T<"clear">lfrtip', | |
121 | tableTools: { | |
122 | sRowSelect: 'os', | |
123 | sRowSelector: 'td:first-child', | |
124 | aButtons: [ 'select_all', 'select_none' ] | |
125 | } | |
126 | } ); | |
127 | } );</code> | |
128 | ||
129 | <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p> | |
130 | ||
131 | <ul> | |
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> | |
135 | </ul> | |
136 | </div> | |
137 | ||
138 | <div class="table"> | |
139 | <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p> | |
140 | </div> | |
141 | ||
142 | <div class="css"> | |
143 | <div> | |
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 { | |
146 | text-align: center; | |
147 | } | |
148 | ||
149 | tr td:first-child:before { | |
150 | content: "\f096"; /* fa-square-o */ | |
151 | font-family: FontAwesome; | |
152 | } | |
153 | ||
154 | tr.selected td:first-child:before { | |
155 | content: "\f046"; /* fa-check-square-o */ | |
156 | }</code> | |
157 | </div> | |
158 | ||
159 | <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p> | |
160 | ||
161 | <ul> | |
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> | |
164 | <li><a href= | |
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> | |
166 | </ul> | |
167 | </div> | |
168 | ||
169 | <div class="ajax"> | |
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 | |
171 | loaded.</p> | |
172 | </div> | |
173 | ||
174 | <div class="php"> | |
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> | |
178 | </div> | |
179 | </div> | |
180 | </section> | |
181 | </div> | |
182 | ||
183 | <section> | |
184 | <div class="footer"> | |
185 | <div class="gradient"></div> | |
186 | ||
187 | <div class="liner"> | |
188 | <h2>Other examples</h2> | |
189 | ||
190 | <div class="toc"> | |
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> | |
212 | </ul> | |
213 | </div> | |
214 | </div> | |
215 | ||
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> | |
220 | ||
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> | |
223 | </div> | |
224 | </div> | |
225 | </div> | |
226 | </section> | |
227 | </body> | |
228 | </html> |