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>ColVis example - Column button callback</title>
9 <link rel="stylesheet" type="text/css" href="../../../media/css/jquery.dataTables.css">
10 <link rel="stylesheet" type="text/css" href="../css/dataTables.colVis.css">
11 <link rel="stylesheet" type="text/css" href="../../../examples/resources/syntax/shCore.css">
12 <link rel="stylesheet" type="text/css" href="../../../examples/resources/demo.css">
13 <style type="text/css" class="init">
16 <script type="text/javascript" language="javascript" src="../../../media/js/jquery.js"></script>
17 <script type="text/javascript" language="javascript" src="../../../media/js/jquery.dataTables.js"></script>
18 <script type="text/javascript" language="javascript" src="../js/dataTables.colVis.js"></script>
19 <script type="text/javascript" language="javascript" src="../../../examples/resources/syntax/shCore.js"></script>
20 <script type="text/javascript" language="javascript" src="../../../examples/resources/demo.js"></script>
21 <script type="text/javascript" language="javascript" class="init">
24 $(document).ready(function() {
25 $('#example').DataTable( {
26 "dom": 'C<"clear">lfrtip',
28 "label": function ( index, title, th ) {
29 return (index+1) +'. '+ title;
39 <body class="dt-example">
40 <div class="container">
42 <h1>ColVis example <span>Column button callback</span></h1>
45 <p>By default ColVis will use the information in the <code class="tag" title="HTML tag">th</code> cell for each column as the button name to use in ColVis, which
46 might not always be what you want (for example you might has HTML in the cell that you don't want in the button). The <code>label</code> callback provides the
47 ability to customise the label used for the button.</p>
49 <p>In this example the column index is prefixed to the column title.</p>
52 <table id="example" class="display" cellspacing="0" width="100%">
78 <td>System Architect</td>
85 <td>Garrett Winters</td>
94 <td>Junior Technical Author</td>
95 <td>San Francisco</td>
101 <td>Cedric Kelly</td>
102 <td>Senior Javascript Developer</td>
117 <td>Brielle Williamson</td>
118 <td>Integration Specialist</td>
125 <td>Herrod Chandler</td>
126 <td>Sales Assistant</td>
127 <td>San Francisco</td>
133 <td>Rhona Davidson</td>
134 <td>Integration Specialist</td>
141 <td>Colleen Hurst</td>
142 <td>Javascript Developer</td>
143 <td>San Francisco</td>
150 <td>Software Engineer</td>
158 <td>Office Manager</td>
166 <td>Support Lead</td>
173 <td>Charde Marshall</td>
174 <td>Regional Director</td>
175 <td>San Francisco</td>
181 <td>Haley Kennedy</td>
182 <td>Senior Marketing Designer</td>
189 <td>Tatyana Fitzpatrick</td>
190 <td>Regional Director</td>
197 <td>Michael Silva</td>
198 <td>Marketing Designer</td>
206 <td>Chief Financial Officer (CFO)</td>
213 <td>Gloria Little</td>
214 <td>Systems Administrator</td>
221 <td>Bradley Greer</td>
222 <td>Software Engineer</td>
230 <td>Personnel Lead</td>
237 <td>Jenette Caldwell</td>
238 <td>Development Lead</td>
246 <td>Chief Marketing Officer (CMO)</td>
253 <td>Caesar Vance</td>
254 <td>Pre-Sales Support</td>
261 <td>Doris Wilder</td>
262 <td>Sales Assistant</td>
269 <td>Angelica Ramos</td>
270 <td>Chief Executive Officer (CEO)</td>
285 <td>Jennifer Chang</td>
286 <td>Regional Director</td>
293 <td>Brenden Wagner</td>
294 <td>Software Engineer</td>
295 <td>San Francisco</td>
302 <td>Chief Operating Officer (COO)</td>
303 <td>San Francisco</td>
310 <td>Regional Marketing</td>
317 <td>Michelle House</td>
318 <td>Integration Specialist</td>
333 <td>Prescott Bartlett</td>
334 <td>Technical Author</td>
341 <td>Gavin Cortez</td>
343 <td>San Francisco</td>
349 <td>Martena Mccray</td>
350 <td>Post-Sales support</td>
357 <td>Unity Butler</td>
358 <td>Marketing Designer</td>
359 <td>San Francisco</td>
365 <td>Howard Hatfield</td>
366 <td>Office Manager</td>
367 <td>San Francisco</td>
373 <td>Hope Fuentes</td>
375 <td>San Francisco</td>
381 <td>Vivian Harrell</td>
382 <td>Financial Controller</td>
383 <td>San Francisco</td>
389 <td>Timothy Mooney</td>
390 <td>Office Manager</td>
397 <td>Jackson Bradshaw</td>
405 <td>Olivia Liang</td>
406 <td>Support Engineer</td>
414 <td>Software Engineer</td>
421 <td>Sakura Yamamoto</td>
422 <td>Support Engineer</td>
437 <td>Finn Camacho</td>
438 <td>Support Engineer</td>
439 <td>San Francisco</td>
445 <td>Serge Baldwin</td>
446 <td>Data Coordinator</td>
453 <td>Zenaida Frank</td>
454 <td>Software Engineer</td>
461 <td>Zorita Serrano</td>
462 <td>Software Engineer</td>
463 <td>San Francisco</td>
469 <td>Jennifer Acosta</td>
470 <td>Junior Javascript Developer</td>
477 <td>Cara Stevens</td>
478 <td>Sales Assistant</td>
485 <td>Hermione Butler</td>
486 <td>Regional Director</td>
494 <td>Systems Administrator</td>
501 <td>Jonas Alexander</td>
503 <td>San Francisco</td>
510 <td>Regional Director</td>
517 <td>Michael Bruce</td>
518 <td>Javascript Developer</td>
525 <td>Donna Snider</td>
526 <td>Customer Support</td>
536 <li class="active">Javascript</li>
540 <li>Server-side script</li>
545 <p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
546 $('#example').DataTable( {
547 "dom": 'C<"clear">lfrtip',
548 "colVis": {
549 "label": function ( index, title, th ) {
550 return (index+1) +'. '+ title;
556 <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
559 <li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
560 <li><a href="../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
561 <li><a href="../js/dataTables.colVis.js">../js/dataTables.colVis.js</a></li>
566 <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
571 <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
572 additional CSS used is shown below:</p><code class="multiline language-css"></code>
575 <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
578 <li><a href="../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
579 <li><a href="../css/dataTables.colVis.css">../css/dataTables.colVis.css</a></li>
584 <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
589 <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
590 processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
591 documentation</a>.</p>
599 <div class="gradient"></div>
602 <h2>Other examples</h2>
605 <div class="toc-group">
606 <h3><a href="./index.html">Examples</a></h3>
607 <ul class="toc active">
608 <li><a href="./simple.html">Basic initialisation</a></li>
609 <li><a href="./new_init.html">`new` initialisation</a></li>
610 <li><a href="./text.html">Custom button text</a></li>
611 <li><a href="./exclude_columns.html">Exclude columns from list</a></li>
612 <li class="active"><a href="./title_callback.html">Column button callback</a></li>
613 <li><a href="./button_order.html">Button ordering</a></li>
614 <li><a href="./mouseover.html">Mouseover activation</a></li>
615 <li><a href="./group_columns.html">Group columns</a></li>
616 <li><a href="./two_tables.html">Two tables with individual controls</a></li>
617 <li><a href="./two_tables_identical.html">Two tables with shared controls</a></li>
618 <li><a href="./restore.html">Restore / show all</a></li>
619 <li><a href="./jqueryui.html">jQuery UI styling</a></li>
624 <div class="epilogue">
625 <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
626 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>
627 which extend the capabilities of DataTables.</p>
629 <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2015<br>
630 DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>