Debian Codegraph @

docs/example-colspan.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Sorting &amp; Filtering with Colspans</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 id="css">.tablesorter-blue td[colspan] { color: red; } /* for demo purposes */</style>
19
20 <script src="../js/jquery.tablesorter.js"></script>
21 <script src="../js/widgets/widget-filter.js"></script>
22
23 <script>
24 $(function() {
25 var dupe = true;
26 $( '#dupe' ).click( function() {
27 dupe = !dupe;
28 $( this ).text( '' + dupe );
29 $( 'table' )[0].config.duplicateSpan = dupe;
30 $( 'table' ).trigger( 'update' );
31 });
32 $('table').on('filterEnd', function( event, c ) {
33 $( '#show-filter' ).html( '[ "' + c.lastSearch.join('", "') + '" ]' );
34 });
35 $('.search').click(function() {
36 var $this = $(this),
37 filter = [],
38 col = $this.attr( 'data-column' );
39 if ( col === 'all' ) {
40 col = $('table')[0].config.columns;
41 }
42 filter[ col ] = $this.text();
43 $.tablesorter.setFilters( $('table'), filter );
44 });
45 });
46 </script>
47
48 <script id="js">$( function() {
49 $( 'table' ).tablesorter({
50 theme : 'blue',
51
52 duplicateSpan : true, // default setting
53
54 widthFixed: true,
55 widgets : [ 'zebra', 'filter' ],
56 widgetOptions : {
57 filter_external: 'input.search',
58 filter_reset: '.reset'
59 }
60 });
61
62 $('.sort').click(function() {
63 // it is still possible to use 'a', 'd', 'n', 's' or 'o' on the second column
64 // see http://mottie.github.io/tablesorter/docs/#sorton
65 $('table').trigger('sorton', [ [[ $(this).text(), 'n' ]] ]);
66 });
67
68 });</script>
69 </head>
70 <body>
71 <div id="banner">
72 <h1>table<em>sorter</em></h1>
73 <h2>Sorting &amp; Filtering with Colspans</h2>
74 <h3>Flexible client-side table sorting</h3>
75 <a href="index.html">Back to documentation</a>
76 </div>
77 <div id="main">
78
79 <p class="tip">
80 <em>NOTE!</em>
81 </p>
82 <ul>
83 <li>Having a <code>colspan</code> in the tbody is not fully supported by all widgets, and there are still some minor issues to work out.</li>
84 <li><span class="label alert">Alert</span> Cells with a <code>rowspan</code> are <em>not</em> currently supported.</li>
85 <li><span class="label warning">Warning</span> Cells with a <code>colspan</code> will attempt to use the parser set for that column and <em>will not</em> use the parser for another column while sorting or filtering - try this <button class="search" data-column="3" type="button">&gt;10</button> - the "17 Koala" cell is not parsed as a numeric value and is thus considered a string.</li>
86 <li>The <a href="index.html#duplicatespan"><code>duplicateSpan</code></a> option (storing of cache data) is a preliminary step in providing <code>colspan</code> support, it is by no means complete.</li>
87 <li>Ignore an entire <em>header</em> row by adding a "tablesorter-ignoreRow" class (set by the <a href="index.html#cssignorerow"><code>cssIgnoreRow</code></a> option).</li>
88 <li>This demo requires tablesorter v2.25.0+, as well the corresponding version of the filter widget.<br><br></li>
89
90 <li>Follow the demo steps to hopefully get the full understanding of how to use <code>colspan</code>s in the tbody.</li>
91 <li>Ultimately, with the issues noted below, I would not recommend including an entire column in the tbody that does not have a corresponding header cell - <em>don't do what I did in this demo for the first two colums</em>.</li>
92 </ul>
93
94 <h1>Demo</h1>
95 <div id="demo"><ul>
96 <li>Sort Column <button class="sort" type="button">0</button> <button class="sort" type="button">1</button>
97 (toggle sort direction) - There is no method to use the UI to sort the second column because it has no header; use "sorton" instead.
98 </li>
99 <li>Search:
100 <button class="search" type="button" data-column="2">zyx</button>
101 <button class="search" type="button" data-column="3">7</button>
102 <button class="search" type="button" data-column="4">Koala</button>
103 <button class="search" type="button" data-column="5">edu</button>,
104 then toggle <code>duplicateSpan</code> : <button id="dupe" type="button">true</button>.
105 </li>
106 <li>Searching the first two columns <sup class="results xsmall">&dagger;</sup>:
107 <ul>
108 <li>Search using column <code>0</code> (zero):<br>
109 <button class="search" type="button" data-column="0">4</button> (nothing visible in column filter)<br>
110 <button class="search" type="button" data-column="1">&gt;4</button> (search second column, nothing visible in filter)
111 </li>
112 <li>Search using column <code>6</code> (used by "all" filter):<br>
113 <button class="search" type="button" data-column="6">4</button> (search both index columns)<sup class="results xsmall">&Dagger;</sup><br>
114 <button class="search" type="button" data-column="6">1:4</button> (only search "Group" column)<br>
115 <button class="search" type="button" data-column="6">2:&gt;4</button> (search second column)
116 </li>
117 </ul>
118 </li>
119 </ul>
120
121 Search:
122 <input type="search" class="search" data-column="all" placeholder="Search all columns"><sup class="results xsmall">&Dagger;</sup>
123 <button type="button" class="reset">Reset</button>
124 <code id="show-filter"></code>
125
126 <p class="xsmall"><span class="results">&dagger;</span> The reason for this issue is that the filter input in the index column has this setting:
127 <code>data-column="0-1"</code>, and it has not yet been worked out how to properly target that input.<br>
128 <span class="results">&Dagger;</span> It is still being investigated as to why the search using the button targeting column 6 and the "all" input have different results (Enter "4" in the input and 4 rows will appear in the result, then click on the "4" to search both index columns - one less row).
129 </p>
130
131 <table class="tablesorter">
132 <thead>
133 <tr class="tablesorter-ignoreRow">
134 <th colspan="6">This entire row is ignored</th>
135 </tr>
136 <tr>
137 <th rowspan="2" colspan="2">Index (colspan 2)</th>
138 <th colspan="4">Products</th>
139 </tr>
140 <tr>
141 <th>Product ID</th>
142 <th>Numeric</th>
143 <th>Animals</th>
144 <th>Url</th>
145 </tr>
146 <tr class="tablesorter-ignoreRow">
147 <th colspan="6">This entire row is ignored too!</th>
148 </tr>
149 </thead>
150 <tfoot>
151 <tr>
152 <th colspan="2">Index</th>
153 <th>Product ID</th>
154 <th>Numeric</th>
155 <th id="test">Animals</th>
156 <th>Url</th>
157 </tr>
158 </tfoot>
159 <tbody>
160 <tr><td>Group 1</td><td style="width:100px">6</td><td>abc 9</td><td>155</td><td>Lion</td><td>http://www.nytimes.com/</td></tr>
161 <tr><td>Group 4</td><td>1</td><td>abc 1</td><td>237</td><td colspan="2">Ox http://www.yahoo.com</td></tr>
162 <tr><td>Group 1</td><td>2</td><td colspan="4">zyx 1 957 Koala http://www.mit.edu/</td></tr>
163 <tr><td>Group 0</td><td>5</td><td>abc 2</td><td>56</td><td>Elephant</td><td>http://www.wikipedia.org/</td></tr>
164 <tr><td>Group 3</td><td>0</td><td>abc 123</td><td colspan="2">17 Koala</td><td>http://www.google.com</td></tr>
165 <tr><td>Group 2</td><td>8</td><td>zyx 9</td><td>10</td><td>Girafee</td><td>http://www.facebook.com</td></tr>
166 <tr><td>Group 1</td><td>3</td><td colspan="2">zyx 4 767</td><td>Bison</td><td>http://www.whitehouse.gov/</td></tr>
167 <tr><td>Group 2</td><td>4</td><td>abc 11</td><td>3</td><td>Chimp</td><td>http://www.ucla.edu/</td></tr>
168 <tr><td>Group 4</td><td>7</td><td colspan="2">ABC 10 87</td><td>Zebra</td><td>http://www.google.com</td></tr>
169 <tr><td>Group 3</td><td>9</td><td>zyx 12</td><td>0</td><td>Koala</td><td>http://www.nasa.gov/</td></tr>
170 </tbody>
171 </table></div>
172
173 <h1>Javascript</h1>
174 <div id="javascript">
175 <pre class="prettyprint lang-javascript"></pre>
176 </div>
177 <h1>CSS</h1>
178 <div id="css">
179 <pre class="prettyprint lang-css"></pre>
180 </div>
181 <h1>HTML</h1>
182 <div id="html">
183 <pre class="prettyprint lang-html"></pre>
184 </div>
185
186 </div>
187
188 </body>
189 </html>