select_single.html 17 KB

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