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 - Initialisation with `new`</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">
24 $(document).ready(function() {
25 var table = $('#example').DataTable();
26 var tt = new $.fn.dataTable.TableTools( table, {
30 $( tt.fnContainer() ).insertAfter('div.info');
37 <body class="dt-example">
38 <div class="container">
40 <h1>TableTools example <span>Initialisation with `new`</span></h1>
43 <p>Typically when working with TableTools, the initialisation and insertion into the DOM will be done automatically by DataTables, through the use of the <a href=
44 "//datatables.net/reference/option/dom"><code class="option" title="DataTables initialisation option">dom<span>DT</span></code></a> parameter. However, it is also
45 possible to initialise TableTools manually as shown in the example below using <code>new $.fn.dataTable.TableTools();</code>. The constructor for TableTools takes
49 <li>The DataTable that the newly created TableTools instance should attach to</li>
50 <li>Optionally - A list of options</li>
53 <p>Once initialised you can insert the TableTools tool bar node anywhere you wish into the DOM using the <code>fnContainer()</code> API method to get the node.</p>
56 <table id="example" class="display" cellspacing="0" width="100%">
82 <td>System Architect</td>
89 <td>Garrett Winters</td>
98 <td>Junior Technical Author</td>
99 <td>San Francisco</td>
105 <td>Cedric Kelly</td>
106 <td>Senior Javascript Developer</td>
121 <td>Brielle Williamson</td>
122 <td>Integration Specialist</td>
129 <td>Herrod Chandler</td>
130 <td>Sales Assistant</td>
131 <td>San Francisco</td>
137 <td>Rhona Davidson</td>
138 <td>Integration Specialist</td>
145 <td>Colleen Hurst</td>
146 <td>Javascript Developer</td>
147 <td>San Francisco</td>
154 <td>Software Engineer</td>
162 <td>Office Manager</td>
170 <td>Support Lead</td>
177 <td>Charde Marshall</td>
178 <td>Regional Director</td>
179 <td>San Francisco</td>
185 <td>Haley Kennedy</td>
186 <td>Senior Marketing Designer</td>
193 <td>Tatyana Fitzpatrick</td>
194 <td>Regional Director</td>
201 <td>Michael Silva</td>
202 <td>Marketing Designer</td>
210 <td>Chief Financial Officer (CFO)</td>
217 <td>Gloria Little</td>
218 <td>Systems Administrator</td>
225 <td>Bradley Greer</td>
226 <td>Software Engineer</td>
234 <td>Personnel Lead</td>
241 <td>Jenette Caldwell</td>
242 <td>Development Lead</td>
250 <td>Chief Marketing Officer (CMO)</td>
257 <td>Caesar Vance</td>
258 <td>Pre-Sales Support</td>
265 <td>Doris Wilder</td>
266 <td>Sales Assistant</td>
273 <td>Angelica Ramos</td>
274 <td>Chief Executive Officer (CEO)</td>
289 <td>Jennifer Chang</td>
290 <td>Regional Director</td>
297 <td>Brenden Wagner</td>
298 <td>Software Engineer</td>
299 <td>San Francisco</td>
306 <td>Chief Operating Officer (COO)</td>
307 <td>San Francisco</td>
314 <td>Regional Marketing</td>
321 <td>Michelle House</td>
322 <td>Integration Specialist</td>
337 <td>Prescott Bartlett</td>
338 <td>Technical Author</td>
345 <td>Gavin Cortez</td>
347 <td>San Francisco</td>
353 <td>Martena Mccray</td>
354 <td>Post-Sales support</td>
361 <td>Unity Butler</td>
362 <td>Marketing Designer</td>
363 <td>San Francisco</td>
369 <td>Howard Hatfield</td>
370 <td>Office Manager</td>
371 <td>San Francisco</td>
377 <td>Hope Fuentes</td>
379 <td>San Francisco</td>
385 <td>Vivian Harrell</td>
386 <td>Financial Controller</td>
387 <td>San Francisco</td>
393 <td>Timothy Mooney</td>
394 <td>Office Manager</td>
401 <td>Jackson Bradshaw</td>
409 <td>Olivia Liang</td>
410 <td>Support Engineer</td>
418 <td>Software Engineer</td>
425 <td>Sakura Yamamoto</td>
426 <td>Support Engineer</td>
441 <td>Finn Camacho</td>
442 <td>Support Engineer</td>
443 <td>San Francisco</td>
449 <td>Serge Baldwin</td>
450 <td>Data Coordinator</td>
457 <td>Zenaida Frank</td>
458 <td>Software Engineer</td>
465 <td>Zorita Serrano</td>
466 <td>Software Engineer</td>
467 <td>San Francisco</td>
473 <td>Jennifer Acosta</td>
474 <td>Junior Javascript Developer</td>
481 <td>Cara Stevens</td>
482 <td>Sales Assistant</td>
489 <td>Hermione Butler</td>
490 <td>Regional Director</td>
498 <td>Systems Administrator</td>
505 <td>Jonas Alexander</td>
507 <td>San Francisco</td>
514 <td>Regional Director</td>
521 <td>Michael Bruce</td>
522 <td>Javascript Developer</td>
529 <td>Donna Snider</td>
530 <td>Customer Support</td>
540 <li class="active">Javascript</li>
544 <li>Server-side script</li>
549 <p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
550 var table = $('#example').DataTable();
551 var tt = new $.fn.dataTable.TableTools( table, {
555 $( tt.fnContainer() ).insertAfter('div.info');
558 <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
561 <li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
562 <li><a href="../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
563 <li><a href="../js/dataTables.tableTools.js">../js/dataTables.tableTools.js</a></li>
568 <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
573 <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
574 additional CSS used is shown below:</p><code class="multiline language-css"></code>
577 <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
580 <li><a href="../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
581 <li><a href="../css/dataTables.tableTools.css">../css/dataTables.tableTools.css</a></li>
586 <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
591 <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
592 processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
593 documentation</a>.</p>
601 <div class="gradient"></div>
604 <h2>Other examples</h2>
607 <div class="toc-group">
608 <h3><a href="./index.html">Examples</a></h3>
609 <ul class="toc active">
610 <li><a href="./simple.html">Basic initialisation</a></li>
611 <li><a href="./swf_path.html">Setting the SWF path</a></li>
612 <li class="active"><a href="./new_init.html">Initialisation with `new`</a></li>
613 <li><a href="./defaults.html">Defaults</a></li>
614 <li><a href="./select_single.html">Row selection - single row select</a></li>
615 <li><a href="./select_multi.html">Row selection - multi-row select</a></li>
616 <li><a href="./select_os.html">Row selection - operating system style</a></li>
617 <li><a href="./select_column.html">Row selection - row selector on specific cells</a></li>
618 <li><a href="./multiple_tables.html">Multiple tables</a></li>
619 <li><a href="./multi_instance.html">Multiple toolbars</a></li>
620 <li><a href="./collection.html">Button collections</a></li>
621 <li><a href="./plug-in.html">Plug-in button types</a></li>
622 <li><a href="./button_text.html">Custom button text</a></li>
623 <li><a href="./alter_buttons.html">Button arrangement</a></li>
624 <li><a href="./ajax.html">Ajax loaded data</a></li>
625 <li><a href="./pdf_message.html">PDF message</a></li>
626 <li><a href="./bootstrap.html">Bootstrap styling</a></li>
627 <li><a href="./jqueryui.html">jQuery UI styling</a></li>
632 <div class="epilogue">
633 <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
634 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>
635 which extend the capabilities of DataTables.</p>
637 <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> © 2007-2015<br>
638 DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>