new_init.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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. <title>ColVis example - `new` initialisation</title>
  8. <link rel="stylesheet" type="text/css" href="../../../media/css/jquery.dataTables.css">
  9. <link rel="stylesheet" type="text/css" href="../css/dataTables.colVis.css">
  10. <link rel="stylesheet" type="text/css" href="../../../examples/resources/syntax/shCore.css">
  11. <link rel="stylesheet" type="text/css" href="../../../examples/resources/demo.css">
  12. <style type="text/css" class="init">
  13. </style>
  14. <script type="text/javascript" language="javascript" src="../../../media/js/jquery.js"></script>
  15. <script type="text/javascript" language="javascript" src="../../../media/js/jquery.dataTables.js"></script>
  16. <script type="text/javascript" language="javascript" src="../js/dataTables.colVis.js"></script>
  17. <script type="text/javascript" language="javascript" src="../../../examples/resources/syntax/shCore.js"></script>
  18. <script type="text/javascript" language="javascript" src="../../../examples/resources/demo.js"></script>
  19. <script type="text/javascript" language="javascript" class="init">
  20. $(document).ready(function() {
  21. var table = $('#example').DataTable();
  22. var colvis = new $.fn.dataTable.ColVis( table );
  23. $( colvis.button() ).insertAfter('div.info');
  24. } );
  25. </script>
  26. </head>
  27. <body class="dt-example">
  28. <div class="container">
  29. <section>
  30. <h1>ColVis example <span>`new` initialisation</span></h1>
  31. <div class="info">
  32. <p>As well as providing the option to be initialised through the <code>C</code> option of <a href="//datatables.net/reference/option/dom"><code class="option"
  33. title="DataTables initialisation option">dom<span>DT</span></code></a>, ColVis can also be added to a DataTable using direct initialisation - <code>new
  34. $.fn.dataTable.ColVis();</code> as shown in this example. The ColVis control button it available through its <code>button()</code> method, which can then be used
  35. to attach to the document where you need.</p>
  36. <p>For full information about the ColVis API, please refer to the <a href="//datatables.net/extensions/colvis/api">ColVis API documentation</a>.</p>
  37. </div>
  38. <table id="example" class="display" cellspacing="0" width="100%">
  39. <thead>
  40. <tr>
  41. <th>Name</th>
  42. <th>Position</th>
  43. <th>Office</th>
  44. <th>Age</th>
  45. <th>Start date</th>
  46. <th>Salary</th>
  47. </tr>
  48. </thead>
  49. <tfoot>
  50. <tr>
  51. <th>Name</th>
  52. <th>Position</th>
  53. <th>Office</th>
  54. <th>Age</th>
  55. <th>Start date</th>
  56. <th>Salary</th>
  57. </tr>
  58. </tfoot>
  59. <tbody>
  60. <tr>
  61. <td>Tiger Nixon</td>
  62. <td>System Architect</td>
  63. <td>Edinburgh</td>
  64. <td>61</td>
  65. <td>2011/04/25</td>
  66. <td>$320,800</td>
  67. </tr>
  68. <tr>
  69. <td>Garrett Winters</td>
  70. <td>Accountant</td>
  71. <td>Tokyo</td>
  72. <td>63</td>
  73. <td>2011/07/25</td>
  74. <td>$170,750</td>
  75. </tr>
  76. <tr>
  77. <td>Ashton Cox</td>
  78. <td>Junior Technical Author</td>
  79. <td>San Francisco</td>
  80. <td>66</td>
  81. <td>2009/01/12</td>
  82. <td>$86,000</td>
  83. </tr>
  84. <tr>
  85. <td>Cedric Kelly</td>
  86. <td>Senior Javascript Developer</td>
  87. <td>Edinburgh</td>
  88. <td>22</td>
  89. <td>2012/03/29</td>
  90. <td>$433,060</td>
  91. </tr>
  92. <tr>
  93. <td>Airi Satou</td>
  94. <td>Accountant</td>
  95. <td>Tokyo</td>
  96. <td>33</td>
  97. <td>2008/11/28</td>
  98. <td>$162,700</td>
  99. </tr>
  100. <tr>
  101. <td>Brielle Williamson</td>
  102. <td>Integration Specialist</td>
  103. <td>New York</td>
  104. <td>61</td>
  105. <td>2012/12/02</td>
  106. <td>$372,000</td>
  107. </tr>
  108. <tr>
  109. <td>Herrod Chandler</td>
  110. <td>Sales Assistant</td>
  111. <td>San Francisco</td>
  112. <td>59</td>
  113. <td>2012/08/06</td>
  114. <td>$137,500</td>
  115. </tr>
  116. <tr>
  117. <td>Rhona Davidson</td>
  118. <td>Integration Specialist</td>
  119. <td>Tokyo</td>
  120. <td>55</td>
  121. <td>2010/10/14</td>
  122. <td>$327,900</td>
  123. </tr>
  124. <tr>
  125. <td>Colleen Hurst</td>
  126. <td>Javascript Developer</td>
  127. <td>San Francisco</td>
  128. <td>39</td>
  129. <td>2009/09/15</td>
  130. <td>$205,500</td>
  131. </tr>
  132. <tr>
  133. <td>Sonya Frost</td>
  134. <td>Software Engineer</td>
  135. <td>Edinburgh</td>
  136. <td>23</td>
  137. <td>2008/12/13</td>
  138. <td>$103,600</td>
  139. </tr>
  140. <tr>
  141. <td>Jena Gaines</td>
  142. <td>Office Manager</td>
  143. <td>London</td>
  144. <td>30</td>
  145. <td>2008/12/19</td>
  146. <td>$90,560</td>
  147. </tr>
  148. <tr>
  149. <td>Quinn Flynn</td>
  150. <td>Support Lead</td>
  151. <td>Edinburgh</td>
  152. <td>22</td>
  153. <td>2013/03/03</td>
  154. <td>$342,000</td>
  155. </tr>
  156. <tr>
  157. <td>Charde Marshall</td>
  158. <td>Regional Director</td>
  159. <td>San Francisco</td>
  160. <td>36</td>
  161. <td>2008/10/16</td>
  162. <td>$470,600</td>
  163. </tr>
  164. <tr>
  165. <td>Haley Kennedy</td>
  166. <td>Senior Marketing Designer</td>
  167. <td>London</td>
  168. <td>43</td>
  169. <td>2012/12/18</td>
  170. <td>$313,500</td>
  171. </tr>
  172. <tr>
  173. <td>Tatyana Fitzpatrick</td>
  174. <td>Regional Director</td>
  175. <td>London</td>
  176. <td>19</td>
  177. <td>2010/03/17</td>
  178. <td>$385,750</td>
  179. </tr>
  180. <tr>
  181. <td>Michael Silva</td>
  182. <td>Marketing Designer</td>
  183. <td>London</td>
  184. <td>66</td>
  185. <td>2012/11/27</td>
  186. <td>$198,500</td>
  187. </tr>
  188. <tr>
  189. <td>Paul Byrd</td>
  190. <td>Chief Financial Officer (CFO)</td>
  191. <td>New York</td>
  192. <td>64</td>
  193. <td>2010/06/09</td>
  194. <td>$725,000</td>
  195. </tr>
  196. <tr>
  197. <td>Gloria Little</td>
  198. <td>Systems Administrator</td>
  199. <td>New York</td>
  200. <td>59</td>
  201. <td>2009/04/10</td>
  202. <td>$237,500</td>
  203. </tr>
  204. <tr>
  205. <td>Bradley Greer</td>
  206. <td>Software Engineer</td>
  207. <td>London</td>
  208. <td>41</td>
  209. <td>2012/10/13</td>
  210. <td>$132,000</td>
  211. </tr>
  212. <tr>
  213. <td>Dai Rios</td>
  214. <td>Personnel Lead</td>
  215. <td>Edinburgh</td>
  216. <td>35</td>
  217. <td>2012/09/26</td>
  218. <td>$217,500</td>
  219. </tr>
  220. <tr>
  221. <td>Jenette Caldwell</td>
  222. <td>Development Lead</td>
  223. <td>New York</td>
  224. <td>30</td>
  225. <td>2011/09/03</td>
  226. <td>$345,000</td>
  227. </tr>
  228. <tr>
  229. <td>Yuri Berry</td>
  230. <td>Chief Marketing Officer (CMO)</td>
  231. <td>New York</td>
  232. <td>40</td>
  233. <td>2009/06/25</td>
  234. <td>$675,000</td>
  235. </tr>
  236. <tr>
  237. <td>Caesar Vance</td>
  238. <td>Pre-Sales Support</td>
  239. <td>New York</td>
  240. <td>21</td>
  241. <td>2011/12/12</td>
  242. <td>$106,450</td>
  243. </tr>
  244. <tr>
  245. <td>Doris Wilder</td>
  246. <td>Sales Assistant</td>
  247. <td>Sidney</td>
  248. <td>23</td>
  249. <td>2010/09/20</td>
  250. <td>$85,600</td>
  251. </tr>
  252. <tr>
  253. <td>Angelica Ramos</td>
  254. <td>Chief Executive Officer (CEO)</td>
  255. <td>London</td>
  256. <td>47</td>
  257. <td>2009/10/09</td>
  258. <td>$1,200,000</td>
  259. </tr>
  260. <tr>
  261. <td>Gavin Joyce</td>
  262. <td>Developer</td>
  263. <td>Edinburgh</td>
  264. <td>42</td>
  265. <td>2010/12/22</td>
  266. <td>$92,575</td>
  267. </tr>
  268. <tr>
  269. <td>Jennifer Chang</td>
  270. <td>Regional Director</td>
  271. <td>Singapore</td>
  272. <td>28</td>
  273. <td>2010/11/14</td>
  274. <td>$357,650</td>
  275. </tr>
  276. <tr>
  277. <td>Brenden Wagner</td>
  278. <td>Software Engineer</td>
  279. <td>San Francisco</td>
  280. <td>28</td>
  281. <td>2011/06/07</td>
  282. <td>$206,850</td>
  283. </tr>
  284. <tr>
  285. <td>Fiona Green</td>
  286. <td>Chief Operating Officer (COO)</td>
  287. <td>San Francisco</td>
  288. <td>48</td>
  289. <td>2010/03/11</td>
  290. <td>$850,000</td>
  291. </tr>
  292. <tr>
  293. <td>Shou Itou</td>
  294. <td>Regional Marketing</td>
  295. <td>Tokyo</td>
  296. <td>20</td>
  297. <td>2011/08/14</td>
  298. <td>$163,000</td>
  299. </tr>
  300. <tr>
  301. <td>Michelle House</td>
  302. <td>Integration Specialist</td>
  303. <td>Sidney</td>
  304. <td>37</td>
  305. <td>2011/06/02</td>
  306. <td>$95,400</td>
  307. </tr>
  308. <tr>
  309. <td>Suki Burks</td>
  310. <td>Developer</td>
  311. <td>London</td>
  312. <td>53</td>
  313. <td>2009/10/22</td>
  314. <td>$114,500</td>
  315. </tr>
  316. <tr>
  317. <td>Prescott Bartlett</td>
  318. <td>Technical Author</td>
  319. <td>London</td>
  320. <td>27</td>
  321. <td>2011/05/07</td>
  322. <td>$145,000</td>
  323. </tr>
  324. <tr>
  325. <td>Gavin Cortez</td>
  326. <td>Team Leader</td>
  327. <td>San Francisco</td>
  328. <td>22</td>
  329. <td>2008/10/26</td>
  330. <td>$235,500</td>
  331. </tr>
  332. <tr>
  333. <td>Martena Mccray</td>
  334. <td>Post-Sales support</td>
  335. <td>Edinburgh</td>
  336. <td>46</td>
  337. <td>2011/03/09</td>
  338. <td>$324,050</td>
  339. </tr>
  340. <tr>
  341. <td>Unity Butler</td>
  342. <td>Marketing Designer</td>
  343. <td>San Francisco</td>
  344. <td>47</td>
  345. <td>2009/12/09</td>
  346. <td>$85,675</td>
  347. </tr>
  348. <tr>
  349. <td>Howard Hatfield</td>
  350. <td>Office Manager</td>
  351. <td>San Francisco</td>
  352. <td>51</td>
  353. <td>2008/12/16</td>
  354. <td>$164,500</td>
  355. </tr>
  356. <tr>
  357. <td>Hope Fuentes</td>
  358. <td>Secretary</td>
  359. <td>San Francisco</td>
  360. <td>41</td>
  361. <td>2010/02/12</td>
  362. <td>$109,850</td>
  363. </tr>
  364. <tr>
  365. <td>Vivian Harrell</td>
  366. <td>Financial Controller</td>
  367. <td>San Francisco</td>
  368. <td>62</td>
  369. <td>2009/02/14</td>
  370. <td>$452,500</td>
  371. </tr>
  372. <tr>
  373. <td>Timothy Mooney</td>
  374. <td>Office Manager</td>
  375. <td>London</td>
  376. <td>37</td>
  377. <td>2008/12/11</td>
  378. <td>$136,200</td>
  379. </tr>
  380. <tr>
  381. <td>Jackson Bradshaw</td>
  382. <td>Director</td>
  383. <td>New York</td>
  384. <td>65</td>
  385. <td>2008/09/26</td>
  386. <td>$645,750</td>
  387. </tr>
  388. <tr>
  389. <td>Olivia Liang</td>
  390. <td>Support Engineer</td>
  391. <td>Singapore</td>
  392. <td>64</td>
  393. <td>2011/02/03</td>
  394. <td>$234,500</td>
  395. </tr>
  396. <tr>
  397. <td>Bruno Nash</td>
  398. <td>Software Engineer</td>
  399. <td>London</td>
  400. <td>38</td>
  401. <td>2011/05/03</td>
  402. <td>$163,500</td>
  403. </tr>
  404. <tr>
  405. <td>Sakura Yamamoto</td>
  406. <td>Support Engineer</td>
  407. <td>Tokyo</td>
  408. <td>37</td>
  409. <td>2009/08/19</td>
  410. <td>$139,575</td>
  411. </tr>
  412. <tr>
  413. <td>Thor Walton</td>
  414. <td>Developer</td>
  415. <td>New York</td>
  416. <td>61</td>
  417. <td>2013/08/11</td>
  418. <td>$98,540</td>
  419. </tr>
  420. <tr>
  421. <td>Finn Camacho</td>
  422. <td>Support Engineer</td>
  423. <td>San Francisco</td>
  424. <td>47</td>
  425. <td>2009/07/07</td>
  426. <td>$87,500</td>
  427. </tr>
  428. <tr>
  429. <td>Serge Baldwin</td>
  430. <td>Data Coordinator</td>
  431. <td>Singapore</td>
  432. <td>64</td>
  433. <td>2012/04/09</td>
  434. <td>$138,575</td>
  435. </tr>
  436. <tr>
  437. <td>Zenaida Frank</td>
  438. <td>Software Engineer</td>
  439. <td>New York</td>
  440. <td>63</td>
  441. <td>2010/01/04</td>
  442. <td>$125,250</td>
  443. </tr>
  444. <tr>
  445. <td>Zorita Serrano</td>
  446. <td>Software Engineer</td>
  447. <td>San Francisco</td>
  448. <td>56</td>
  449. <td>2012/06/01</td>
  450. <td>$115,000</td>
  451. </tr>
  452. <tr>
  453. <td>Jennifer Acosta</td>
  454. <td>Junior Javascript Developer</td>
  455. <td>Edinburgh</td>
  456. <td>43</td>
  457. <td>2013/02/01</td>
  458. <td>$75,650</td>
  459. </tr>
  460. <tr>
  461. <td>Cara Stevens</td>
  462. <td>Sales Assistant</td>
  463. <td>New York</td>
  464. <td>46</td>
  465. <td>2011/12/06</td>
  466. <td>$145,600</td>
  467. </tr>
  468. <tr>
  469. <td>Hermione Butler</td>
  470. <td>Regional Director</td>
  471. <td>London</td>
  472. <td>47</td>
  473. <td>2011/03/21</td>
  474. <td>$356,250</td>
  475. </tr>
  476. <tr>
  477. <td>Lael Greer</td>
  478. <td>Systems Administrator</td>
  479. <td>London</td>
  480. <td>21</td>
  481. <td>2009/02/27</td>
  482. <td>$103,500</td>
  483. </tr>
  484. <tr>
  485. <td>Jonas Alexander</td>
  486. <td>Developer</td>
  487. <td>San Francisco</td>
  488. <td>30</td>
  489. <td>2010/07/14</td>
  490. <td>$86,500</td>
  491. </tr>
  492. <tr>
  493. <td>Shad Decker</td>
  494. <td>Regional Director</td>
  495. <td>Edinburgh</td>
  496. <td>51</td>
  497. <td>2008/11/13</td>
  498. <td>$183,000</td>
  499. </tr>
  500. <tr>
  501. <td>Michael Bruce</td>
  502. <td>Javascript Developer</td>
  503. <td>Singapore</td>
  504. <td>29</td>
  505. <td>2011/06/27</td>
  506. <td>$183,000</td>
  507. </tr>
  508. <tr>
  509. <td>Donna Snider</td>
  510. <td>Customer Support</td>
  511. <td>New York</td>
  512. <td>27</td>
  513. <td>2011/01/25</td>
  514. <td>$112,000</td>
  515. </tr>
  516. </tbody>
  517. </table>
  518. <ul class="tabs">
  519. <li class="active">Javascript</li>
  520. <li>HTML</li>
  521. <li>CSS</li>
  522. <li>Ajax</li>
  523. <li>Server-side script</li>
  524. </ul>
  525. <div class="tabs">
  526. <div class="js">
  527. <p>The Javascript shown below is used to initialise the table shown in this example:</p><code class="multiline language-js">$(document).ready(function() {
  528. var table = $('#example').DataTable();
  529. var colvis = new $.fn.dataTable.ColVis( table );
  530. $( colvis.button() ).insertAfter('div.info');
  531. } );</code>
  532. <p>In addition to the above code, the following Javascript library files are loaded for use in this example:</p>
  533. <ul>
  534. <li><a href="../../../media/js/jquery.js">../../../media/js/jquery.js</a></li>
  535. <li><a href="../../../media/js/jquery.dataTables.js">../../../media/js/jquery.dataTables.js</a></li>
  536. <li><a href="../js/dataTables.colVis.js">../js/dataTables.colVis.js</a></li>
  537. </ul>
  538. </div>
  539. <div class="table">
  540. <p>The HTML shown below is the raw HTML table element, before it has been enhanced by DataTables:</p>
  541. </div>
  542. <div class="css">
  543. <div>
  544. <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
  545. additional CSS used is shown below:</p><code class="multiline language-css"></code>
  546. </div>
  547. <p>The following CSS library files are loaded for use in this example to provide the styling of the table:</p>
  548. <ul>
  549. <li><a href="../../../media/css/jquery.dataTables.css">../../../media/css/jquery.dataTables.css</a></li>
  550. <li><a href="../css/dataTables.colVis.css">../css/dataTables.colVis.css</a></li>
  551. </ul>
  552. </div>
  553. <div class="ajax">
  554. <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
  555. loaded.</p>
  556. </div>
  557. <div class="php">
  558. <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
  559. processing scripts can be written in any language, using <a href="//datatables.net/manual/server-side">the protocol described in the DataTables
  560. documentation</a>.</p>
  561. </div>
  562. </div>
  563. </section>
  564. </div>
  565. <section>
  566. <div class="footer">
  567. <div class="gradient"></div>
  568. <div class="liner">
  569. <h2>Other examples</h2>
  570. <div class="toc">
  571. <div class="toc-group">
  572. <h3><a href="./index.html">Examples</a></h3>
  573. <ul class="toc active">
  574. <li><a href="./simple.html">Basic initialisation</a></li>
  575. <li class="active"><a href="./new_init.html">`new` initialisation</a></li>
  576. <li><a href="./text.html">Custom button text</a></li>
  577. <li><a href="./exclude_columns.html">Exclude columns from list</a></li>
  578. <li><a href="./title_callback.html">Column button callback</a></li>
  579. <li><a href="./button_order.html">Button ordering</a></li>
  580. <li><a href="./mouseover.html">Mouseover activation</a></li>
  581. <li><a href="./group_columns.html">Group columns</a></li>
  582. <li><a href="./two_tables.html">Two tables with individual controls</a></li>
  583. <li><a href="./two_tables_identical.html">Two tables with shared controls</a></li>
  584. <li><a href="./restore.html">Restore / show all</a></li>
  585. <li><a href="./jqueryui.html">jQuery UI styling</a></li>
  586. </ul>
  587. </div>
  588. </div>
  589. <div class="epilogue">
  590. <p>Please refer to the <a href="http://www.datatables.net">DataTables documentation</a> for full information about its API properties and methods.<br>
  591. 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>
  592. which extend the capabilities of DataTables.</p>
  593. <p class="copyright">DataTables designed and created by <a href="http://www.sprymedia.co.uk">SpryMedia Ltd</a> &#169; 2007-2015<br>
  594. DataTables is licensed under the <a href="http://www.datatables.net/mit">MIT license</a>.</p>
  595. </div>
  596. </div>
  597. </div>
  598. </section>
  599. </body>
  600. </html>