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 - Plug-in button types
</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=
"../../../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.tableTools.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">
25 $.fn.dataTable.TableTools.buttons.copy_to_div = $.extend(
28 $.fn.dataTable.TableTools.buttonBase,
31 "sButtonText":
"Copy to element",
33 "fnClick": function( button, conf ) {
34 $(conf.target).html( this.fnGetTableData(conf) );
40 $(document).ready(function() {
41 $('#example').DataTable( {
42 dom: 'T<
"clear">lfrtip',
45 "sExtends":
"copy_to_div",
46 "sButtonText":
"Copy to HTML",
57 <body class=
"dt-example">
58 <div class=
"container">
60 <h1>TableTools example
<span>Plug-in button types
</span></h1>
63 <p>This example shows now a plug-in button type can be created for TableTools. Button types are attached to the
<code>$.fn.dataTable.TableTools.buttons
</code>
64 object and extend
<code>$.fn.dataTable.TableTools.buttonBase
</code>. All of the
<a href=
"//datatables.net/extensions/tabletools/button_options">button options
65 defined in the documentation
</a> are available and can be overridden as required. Finally to use the button simply include its name in the
<code>aButtons
</code>
66 array or use it as a button extender (
<code>sExtends
</code>).
</p>
68 <p>This example shows a button which will simply get the data contents of a table and set that as the contents of another element.
</p>
71 <div id=
"copy" class=
"box" style=
"height: 100px; overflow: auto">
72 Copy output will go here
75 <table id=
"example" class=
"display" cellspacing=
"0" width=
"100%">
101 <td>System Architect
</td>
108 <td>Garrett Winters
</td>
117 <td>Junior Technical Author
</td>
118 <td>San Francisco
</td>
124 <td>Cedric Kelly
</td>
125 <td>Senior Javascript Developer
</td>
140 <td>Brielle Williamson
</td>
141 <td>Integration Specialist
</td>
148 <td>Herrod Chandler
</td>
149 <td>Sales Assistant
</td>
150 <td>San Francisco
</td>
156 <td>Rhona Davidson
</td>
157 <td>Integration Specialist
</td>
164 <td>Colleen Hurst
</td>
165 <td>Javascript Developer
</td>
166 <td>San Francisco
</td>
173 <td>Software Engineer
</td>
181 <td>Office Manager
</td>
189 <td>Support Lead
</td>
196 <td>Charde Marshall
</td>
197 <td>Regional Director
</td>
198 <td>San Francisco
</td>
204 <td>Haley Kennedy
</td>
205 <td>Senior Marketing Designer
</td>
212 <td>Tatyana Fitzpatrick
</td>
213 <td>Regional Director
</td>
220 <td>Michael Silva
</td>
221 <td>Marketing Designer
</td>
229 <td>Chief Financial Officer (CFO)
</td>
236 <td>Gloria Little
</td>
237 <td>Systems Administrator
</td>
244 <td>Bradley Greer
</td>
245 <td>Software Engineer
</td>
253 <td>Personnel Lead
</td>
260 <td>Jenette Caldwell
</td>
261 <td>Development Lead
</td>
269 <td>Chief Marketing Officer (CMO)
</td>
276 <td>Caesar Vance
</td>
277 <td>Pre-Sales Support
</td>
284 <td>Doris Wilder
</td>
285 <td>Sales Assistant
</td>
292 <td>Angelica Ramos
</td>
293 <td>Chief Executive Officer (CEO)
</td>
308 <td>Jennifer Chang
</td>
309 <td>Regional Director
</td>
316 <td>Brenden Wagner
</td>
317 <td>Software Engineer
</td>
318 <td>San Francisco
</td>
325 <td>Chief Operating Officer (COO)
</td>
326 <td>San Francisco
</td>
333 <td>Regional Marketing
</td>
340 <td>Michelle House
</td>
341 <td>Integration Specialist
</td>
356 <td>Prescott Bartlett
</td>
357 <td>Technical Author
</td>
364 <td>Gavin Cortez
</td>
366 <td>San Francisco
</td>
372 <td>Martena Mccray
</td>
373 <td>Post-Sales support
</td>
380 <td>Unity Butler
</td>
381 <td>Marketing Designer
</td>
382 <td>San Francisco
</td>
388 <td>Howard Hatfield
</td>
389 <td>Office Manager
</td>
390 <td>San Francisco
</td>
396 <td>Hope Fuentes
</td>
398 <td>San Francisco
</td>
404 <td>Vivian Harrell
</td>
405 <td>Financial Controller
</td>
406 <td>San Francisco
</td>
412 <td>Timothy Mooney
</td>
413 <td>Office Manager
</td>
420 <td>Jackson Bradshaw
</td>
428 <td>Olivia Liang
</td>
429 <td>Support Engineer
</td>
437 <td>Software Engineer
</td>
444 <td>Sakura Yamamoto
</td>
445 <td>Support Engineer
</td>
460 <td>Finn Camacho
</td>
461 <td>Support Engineer
</td>
462 <td>San Francisco
</td>
468 <td>Serge Baldwin
</td>
469 <td>Data Coordinator
</td>
476 <td>Zenaida Frank
</td>
477 <td>Software Engineer
</td>
484 <td>Zorita Serrano
</td>
485 <td>Software Engineer
</td>
486 <td>San Francisco
</td>
492 <td>Jennifer Acosta
</td>
493 <td>Junior Javascript Developer
</td>
500 <td>Cara Stevens
</td>
501 <td>Sales Assistant
</td>
508 <td>Hermione Butler
</td>
509 <td>Regional Director
</td>
517 <td>Systems Administrator
</td>
524 <td>Jonas Alexander
</td>
526 <td>San Francisco
</td>
533 <td>Regional Director
</td>
540 <td>Michael Bruce
</td>
541 <td>Javascript Developer
</td>
548 <td>Donna Snider
</td>
549 <td>Customer Support
</td>
559 <li class=
"active">Javascript
</li>
563 <li>Server-side script
</li>
568 <p>The Javascript shown below is used to initialise the table shown in this example:
</p><code class=
"multiline language-js">$.fn.dataTable.TableTools.buttons.copy_to_div = $.extend(
571 $.fn.dataTable.TableTools.buttonBase,
573 "sNewLine
":
"<br
>",
574 "sButtonText
":
"Copy to element
",
575 "target
":
"",
576 "fnClick
": function( button, conf ) {
577 $(conf.target).html( this.fnGetTableData(conf) );
583 $(document).ready(function() {
584 $('#example').DataTable( {
585 dom: 'T
<"clear
">lfrtip',
587 "aButtons
": [ {
588 "sExtends
":
"copy_to_div
",
589 "sButtonText
":
"Copy to HTML
",
590 "target
":
"#copy
"
596 <p>In addition to the above code, the following Javascript library files are loaded for use in this example:
</p>
599 <li><a href=
"../../../media/js/jquery.js">../../../media/js/jquery.js
</a></li>
600 <li><a href=
"../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js
</a></li>
601 <li><a href=
"../js/dataTables.tableTools.js">../js/dataTables.tableTools.js
</a></li>
606 <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:
</p>
611 <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
612 additional CSS used is shown below:
</p><code class=
"multiline language-css"></code>
615 <p>The following CSS library files are loaded for use in this example to provide the styling of the table:
</p>
618 <li><a href=
"../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css
</a></li>
619 <li><a href=
"../css/dataTables.tableTools.css">../css/dataTables.tableTools.css
</a></li>
624 <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
629 <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
630 processing scripts can be written in any language, using
<a href=
"//datatables.net/manual/server-side">the protocol described in the DataTables
631 documentation
</a>.
</p>
639 <div class=
"gradient"></div>
642 <h2>Other examples
</h2>
645 <div class=
"toc-group">
646 <h3><a href=
"./index.html">Examples
</a></h3>
647 <ul class=
"toc active">
648 <li><a href=
"./simple.html">Basic initialisation
</a></li>
649 <li><a href=
"./swf_path.html">Setting the SWF path
</a></li>
650 <li><a href=
"./new_init.html">Initialisation with `new`
</a></li>
651 <li><a href=
"./defaults.html">Defaults
</a></li>
652 <li><a href=
"./select_single.html">Row selection - single row select
</a></li>
653 <li><a href=
"./select_multi.html">Row selection - multi-row select
</a></li>
654 <li><a href=
"./select_os.html">Row selection - operating system style
</a></li>
655 <li><a href=
"./select_column.html">Row selection - row selector on specific cells
</a></li>
656 <li><a href=
"./multiple_tables.html">Multiple tables
</a></li>
657 <li><a href=
"./multi_instance.html">Multiple toolbars
</a></li>
658 <li><a href=
"./collection.html">Button collections
</a></li>
659 <li class=
"active"><a href=
"./plug-in.html">Plug-in button types
</a></li>
660 <li><a href=
"./button_text.html">Custom button text
</a></li>
661 <li><a href=
"./alter_buttons.html">Button arrangement
</a></li>
662 <li><a href=
"./ajax.html">Ajax loaded data
</a></li>
663 <li><a href=
"./pdf_message.html">PDF message
</a></li>
664 <li><a href=
"./bootstrap.html">Bootstrap styling
</a></li>
665 <li><a href=
"./jqueryui.html">jQuery UI styling
</a></li>
670 <div class=
"epilogue">
671 <p>Please refer to the
<a href=
"http://www.datatables.net">DataTables documentation
</a> for full information about its API properties and methods.
<br>
672 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>
673 which extend the capabilities of DataTables.
</p>
675 <p class=
"copyright">DataTables designed and created by
<a href=
"http://www.sprymedia.co.uk">SpryMedia Ltd
</a> © 2007-
2015<br>
676 DataTables is licensed under the
<a href=
"http://www.datatables.net/mit">MIT license
</a>.
</p>