Debian Codegraph @

docs/example-option-sort-append.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Append a default sorting order</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 <style>
19 th { width: 16.7%; }
20 #result1, #result2 { color: red; font-size: .8em; font-weight: normal; vertical-align: text-top; }
21 </style>
22 <script src="../js/jquery.tablesorter.js"></script>
23
24 <script id="js">$(function() {
25 $('#table1').tablesorter({
26 theme : 'blue',
27
28 // add sort on the first column and in ascending order AFTER the selected column
29 sortAppend: [[0,0]]
30 });
31
32 $('#table2').tablesorter({
33 theme : 'blue',
34
35 // append different sort based on the first column sorted
36 sortAppend: {
37 0 : [[ 1, 'a' ]], // always apply ascending sort
38 2 : [[ 3, 'o' ]], // sort "o"pposite of column 2 direction
39 4 : [[ 5, 's' ], [ 0, 's' ] ] // sort "s"ame as column 4 direction
40 }
41 });
42 });</script>
43 <script>
44 $(function() {
45 // show sortList
46 $('table').on('sortEnd', function() {
47 var indx,
48 list = '&nbsp;[ ',
49 sortList = this.config.sortList,
50 id = '#result' + this.id.match(/\d/);
51 for ( indx = 0; indx < sortList.length; indx++ ) {
52 list += '[ ' + sortList[ indx ].join( ',' ) + ' ]';
53 if ( indx < sortList.length - 1 ) {
54 list += ', ';
55 }
56 }
57 $(id).html( list + ' ]' );
58 });
59 });
60 </script>
61 </head>
62 <body>
63
64 <div id="banner">
65 <h1>table<em>sorter</em></h1>
66 <h2>Append to a sort order</h2>
67 <h3>Flexible client-side table sorting</h3>
68 <a href="index.html">Back to documentation</a>
69 </div>
70
71 <div id="main">
72
73 <p class="tip">
74 <em>NOTE!</em>
75 </p>
76 <ul>
77 <li>In <span class="version">v2.24.0</span>, <code>sortAppend</code> can now be applied based on the primary column sort.</li>
78 <li>Click to sort any column header to see the the first column sort is appended to the selected sort order.</li>
79 <li>This option is part of the original plugin</li>
80 </ul>
81
82 <h1>Demo</h1>
83 <div id="demo"><h4>"First Name" column ascending sort appended to any other sort: <small id="result1"></small></h4>
84 <table id="table1" class="tablesorter">
85 <thead>
86 <tr><th>First Name</th><th>Last Name</th><th>Age</th><th>Total</th><th>Discount</th><th>Date</th></tr>
87 </thead>
88 <tbody>
89 <tr><td>Peter</td><td>Parker</td><td>28</td><td>$9.99</td><td>20%</td><td>Jan 18, 2001 9:12 AM</td></tr>
90 <tr><td>John</td><td>Evans</td><td>33</td><td>$9.99</td><td>25%</td><td>Dec 10, 2002 5:14 AM</td></tr>
91 <tr><td>Clark</td><td>Kent</td><td>22</td><td>$15.89</td><td>44%</td><td>Jan 12, 2003 11:14 AM</td></tr>
92 <tr><td>Bruce</td><td>Almighty</td><td>45</td><td>$15.89</td><td>44%</td><td>Jan 18, 2001 9:12 AM</td></tr>
93 <tr><td>Bruce</td><td>Evans</td><td>22</td><td>$13.19</td><td>11%</td><td>Jul 6, 2006 8:14 AM</td></tr>
94 </tbody>
95 </table>
96
97 <h4>Append sorted column based on initially sorted column: <small id="result2"></small></h4>
98 <table id="table2" class="tablesorter">
99 <thead>
100 <tr><th>First Name (+Last)</th><th>Last Name</th><th>Age (+Total)</th><th>Total</th><th>Discount (+Date & First)</th><th>Date</th></tr>
101 </thead>
102 <tbody>
103 <tr><td>Peter</td><td>Parker</td><td>28</td><td>$9.99</td><td>20%</td><td>Jan 18, 2001 9:12 AM</td></tr>
104 <tr><td>John</td><td>Evans</td><td>33</td><td>$9.99</td><td>25%</td><td>Dec 10, 2002 5:14 AM</td></tr>
105 <tr><td>Clark</td><td>Kent</td><td>22</td><td>$15.89</td><td>44%</td><td>Jan 12, 2003 11:14 AM</td></tr>
106 <tr><td>Bruce</td><td>Almighty</td><td>45</td><td>$15.89</td><td>44%</td><td>Jan 18, 2001 9:12 AM</td></tr>
107 <tr><td>Bruce</td><td>Evans</td><td>22</td><td>$13.19</td><td>11%</td><td>Jul 6, 2006 8:14 AM</td></tr>
108 </tbody>
109 </table></div>
110
111 <h1>Javascript</h1>
112 <div id="javascript">
113 <pre class="prettyprint lang-javascript"></pre>
114 </div>
115 <h1>HTML</h1>
116 <div id="html">
117 <pre class="prettyprint lang-html"></pre>
118 </div>
119
120 <div class="next-up">
121 <hr />
122 Next up: <a href="example-child-rows.html">Working with Child Rows &rsaquo;&rsaquo;</a>
123 </div>
124
125 </div>
126
127 </body>
128 </html>