Debian Codegraph @

docs/example-add-rows.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Adding a table row</title>
6
7 <!-- jQuery -->
8 <script src="js/jquery-latest.min.js"></script>
9
10 <!-- Demo stuff -->
11 <link rel="stylesheet" href="css/jq.css">
12 <link href="css/prettify.css" rel="stylesheet">
13 <script src="js/prettify.js"></script>
14 <script src="js/docs.js"></script>
15
16 <!-- Tablesorter: required -->
17 <link rel="stylesheet" href="../css/theme.blue.css">
18 <script src="../js/jquery.tablesorter.js"></script>
19
20 <style>
21 .discount { cursor: pointer; }
22 </style>
23
24 <script id="js">$(function() {
25
26 $("table").tablesorter({ theme : 'blue', sortList: [[3,1],[0,0]] });
27
28 // Add two new rows using the "addRows" method
29 // the "update" method doesn't work here because not all
30 // rows are present in the table when the pager is applied
31 $('button').click(function() {
32 // add two rows
33 var row = '<tr><td>Frank</td><td>Smith</td><td>53</td><td>$39.95</td><td>22%</td><td>Mar 22, 2011 9:33 AM</td></tr>' +
34 '<tr><td>Inigo</td><td>Montoya</td><td>34</td><td>$19.99</td><td>15%</td><td>Sep 25, 1987 12:00PM</td></tr>',
35 $row = $(row),
36 // resort table using the current sort; set to false to prevent resort, otherwise
37 // any other value in resort will automatically trigger the table resort.
38 resort = true;
39 $('table')
40 .find('tbody').append($row)
41 .trigger('addRows', [$row, resort]);
42 return false;
43 });
44
45 });</script>
46 </head>
47 <body>
48
49 <div id="banner">
50 <h1>table<em>sorter</em></h1>
51 <h2>Adding table rows</h2>
52 <h3>Flexible client-side table sorting</h3>
53 <a href="index.html">Back to documentation</a>
54 </div>
55
56 <div id="main">
57
58 <p class="tip">
59 <em>NOTE!</em>
60 </p>
61 <ul>
62 <li>Click on the [ Add Rows ] button to add two new rows.</li>
63 <li>The "addRows" method was added in version 2.0.16, and is not part of the original plugin.</li>
64 <li>This example could have used the "update" method to add rows, but to remove rows only the "update" method works.</li>
65 <li>This method is better used for the <a href="example-pager.html">pager plugin</a> when not all of the rows are displayed.</li>
66 </ul>
67
68 <h1>Demo</h1>
69 <br>
70 <button type="button">Add Rows</button>
71 <br>
72 <div id="demo"><table class="tablesorter">
73 <thead>
74 <tr>
75 <th>First Name</th>
76 <th>Last Name</th>
77 <th>Age</th>
78 <th>Total</th>
79 <th>Discount</th>
80 <th>Date</th>
81 </tr>
82 </thead>
83 <tbody>
84 <tr>
85 <td>Peter</td>
86 <td>Parker</td>
87 <td>28</td>
88 <td class="discount">$9.99</td>
89 <td>20%</td>
90 <td>Jul 6, 2006 8:14 AM</td>
91 </tr>
92 <tr>
93 <td>John</td>
94 <td>Hood</td>
95 <td>33</td>
96 <td class="discount">$19.99</td>
97 <td>25%</td>
98 <td>Dec 10, 2002 5:14 AM</td>
99 </tr>
100 <tr>
101 <td>Clark</td>
102 <td>Kent</td>
103 <td>18</td>
104 <td class="discount">$15.89</td>
105 <td>44%</td>
106 <td>Jan 12, 2003 11:14 AM</td>
107 </tr>
108 <tr>
109 <td>Bruce</td>
110 <td>Almighty</td>
111 <td>45</td>
112 <td class="discount">$153.19</td>
113 <td>44%</td>
114 <td>Jan 18, 2001 9:12 AM</td>
115 </tr>
116 <tr>
117 <td>Bruce</td>
118 <td>Evans</td>
119 <td>22</td>
120 <td class="discount">$13.19</td>
121 <td>11%</td>
122 <td>Jan 18, 2007 9:12 AM</td>
123 </tr>
124 </tbody>
125 </table></div>
126
127 <h1>Javascript</h1>
128 <div id="javascript">
129 <pre class="prettyprint lang-javascript"></pre>
130 </div>
131 <h1>HTML</h1>
132 <div id="html">
133 <pre class="prettyprint lang-html"></pre>
134 </div>
135
136 <div class="next-up">
137 <hr />
138 Next up: <a href="example-update-all.html">Update an entire table column (thead and tbody) &rsaquo;&rsaquo;</a>
139 </div>
140
141 </div>
142
143 </body>
144 </html>