Debian Codegraph @

docs/example-widget-output.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Output Widget</title>
6
7 <!-- jQuery -->
8 <script src="js/jquery-latest.min.js"></script>
9
10 <!-- Demo stuff -->
11 <link class="ui-theme" rel="stylesheet" href="css/jquery-ui.min.css">
12 <script src="js/jquery-ui.min.js"></script>
13 <link rel="stylesheet" href="css/bootstrap-v3.min.css">
14 <script src="js/bootstrap.min.js"></script><!-- -->
15 <link href="css/jq.css" rel="stylesheet">
16 <link href="css/prettify.css" rel="stylesheet">
17 <link href="css/tipsy.css" rel="stylesheet">
18 <script src="js/prettify.js"></script>
19 <script src="js/docs.js"></script>
20 <script src="js/jquery.tipsy.min.js"></script>
21 <style>
22 .red {
23 color: red;
24 }
25 .accordion a {
26 color: #2A6496;
27 }
28 .ts-pager, select.btn-sm {
29 display: inline-block;
30 }
31 select.btn-sm {
32 width: 50px;
33 height: 30px;
34 vertical-align: top;
35 }
36 .dropdown-menu {
37 min-width: 320px;
38 font-size: 12px;
39 padding: 10px;
40 }
41 .dropdown-menu h5 {
42 text-align: right;
43 margin-right: 4px;
44 }
45 .dropdown-menu li div {
46 margin-bottom: 5px;
47 }
48 .output-separator, .output-replacequotes, .output-quotes {
49 font-family: Tahoma, Geneva, sans-serif;
50 min-width: 18px;
51 height: 22px;
52 }
53 .output-separator-input, .output-replacequotes {
54 width: 26px;
55 }
56 pre {
57 /* override bootstrap setting */
58 overflow-y: hidden !important;
59 }
60 </style>
61 <style id="css">table.tablesorter tbody tr.odd.checked td {
62 background: #8080c0;
63 color: #fff;
64 }
65 table.tablesorter tbody tr.even.checked td {
66 background: #a0a0e0;
67 color: #fff;
68 }</style>
69
70 <!-- Tablesorter: required -->
71 <link rel="stylesheet" href="../css/theme.bootstrap.css">
72 <link rel="stylesheet" href="../css/theme.blue.css">
73 <script src="../js/jquery.tablesorter.js"></script>
74 <script src="../js/jquery.tablesorter.widgets.js"></script>
75 <script src="../js/widgets/widget-output.js"></script>
76 <script src="../js/parsers/parser-input-select.js"></script>
77
78 <!-- Tablesorter: optional -->
79 <link rel="stylesheet" href="../addons/pager/jquery.tablesorter.pager.css">
80 <script src="../addons/pager/jquery.tablesorter.pager.js"></script>
81 <script>
82 $(function() {
83 $('#output-options').tablesorter({
84 theme: 'bootstrap',
85 widthFixed : true,
86 headerTemplate : '{content} {icon}',
87 widgets: ["zebra", "stickyHeaders", "uitheme"]
88 });
89
90 // External search
91 // buttons set up like this:
92 // <button type="button" data-filter-column="4" data-filter-text="2?%">Saved Search</button>
93 $('button[data-filter-column]').click(function() {
94 /*** first method *** data-filter-column="2" data-filter-text="!son"
95 add search value to Discount column (zero based index) input */
96 var filters = [],
97 $t = $(this),
98 col = $t.data('filter-column'), // zero-based index
99 txt = $t.data('filter-text') || $t.text(); // text to add to filter
100 filters[col] = txt;
101 // using "table.hasFilters" here to make sure we aren't targeting a sticky header
102 $.tablesorter.setFilters( $('table.hasFilters'), filters, true ); // new v2.9
103 return false;
104 });
105
106 });
107 </script>
108
109 <script id="js">$(function() {
110
111 $('.group1 table').tablesorter({
112 theme: 'bootstrap',
113 checkboxClass : 'checked', // default setting
114 widthFixed : true,
115 headerTemplate : '{content} {icon}',
116 widgets: ["zebra", "filter", "uitheme", "output"],
117 widgetOptions : {
118 filter_filteredRow : 'filtered',
119 filter_reset : '.group1 .reset',
120
121 output_separator : ',', // ',' 'json', 'array' or separator (e.g. ';')
122 output_ignoreColumns : [0], // columns to ignore [0, 1,... ] (zero-based index)
123 output_hiddenColumns : false, // include hidden columns in the output
124 output_includeFooter : true, // include footer rows in the output
125 output_includeHeader : true, // include header rows in the output
126 output_headerRows : false, // output all header rows (if multiple rows)
127 output_dataAttrib : 'data-name', // data-attribute containing alternate cell text
128 output_delivery : 'p', // (p)opup, (d)ownload
129 output_saveRows : 'f', // (a)ll, (v)isible, (f)iltered, jQuery filter selector (string only) or filter function
130 output_duplicateSpans: true, // duplicate output data in tbody colspan/rowspan
131 output_replaceQuote : '\u201c;', // change quote to left double quote
132 output_includeHTML : true, // output includes all cell HTML (except the header cells)
133 output_trimSpaces : false, // remove extra white-space characters from beginning & end
134 output_wrapQuotes : false, // wrap every cell output in quotes
135 output_popupStyle : 'width=580,height=310',
136 output_saveFileName : 'mytable.csv',
137 // callback executed after the content of the table has been processed
138 output_formatContent : function(config, widgetOptions, data) {
139 // data.isHeader (boolean) = true if processing a header cell
140 // data.$cell = jQuery object of the cell currently being processed
141 // data.content = processed cell content (spaces trimmed, quotes added/replaced, etc)
142 // data.columnIndex = column in which the cell is contained
143 // data.parsed = cell content parsed by the associated column parser
144 return data.content;
145 },
146 // callback executed when processing completes
147 output_callback : function(config, data, url) {
148 // return false to stop delivery & do something else with the data
149 // return true OR modified data (v2.25.1) to continue download/output
150 return true;
151 },
152 // callbackJSON used when outputting JSON & any header cells has a colspan - unique names required
153 output_callbackJSON : function($cell, txt, cellIndex) {
154 return txt + '(' + cellIndex + ')';
155 },
156 // the need to modify this for Excel no longer exists
157 output_encoding : 'data:application/octet-stream;charset=utf8,',
158 // override internal save file code and use an external plugin such as
159 // https://github.com/eligrey/FileSaver.js
160 output_savePlugin : null /* function(config, widgetOptions, data) {
161 var blob = new Blob([data], {type: widgetOptions.output_encoding});
162 saveAs(blob, widgetOptions.output_saveFileName);
163 } */
164 }
165 }).tablesorterPager({
166 container: $('.ts-pager'),
167 output: '{startRow} - {endRow} / {filteredRows} ({totalRows})',
168 size: 5
169 });
170
171 $('.group2 table').tablesorter({
172 theme: 'bootstrap',
173 widthFixed : true,
174 headerTemplate : '{content} {icon}',
175 widgets: ["zebra", "filter", "uitheme", "output"],
176 widgetOptions : {
177 filter_filteredRow : 'filtered',
178 filter_reset : '.group2 .reset',
179 output_headerRows : true, // output all header rows (multiple rows)
180 output_popupStyle : 'width=580,height=310',
181 output_saveFileName : 'mytable.csv'
182 }
183 });
184
185 // set up download buttons for two table groups
186 var demos = ['.group1', '.group2'];
187
188 $.each(demos, function(groupIndex) {
189 var $this = $(demos[groupIndex]);
190
191 $this.find('.dropdown-toggle').click(function(e) {
192 // this is needed because clicking inside the dropdown will close
193 // the menu with only bootstrap controlling it.
194 $this.find('.dropdown-menu').toggle();
195 return false;
196 });
197 // make separator & replace quotes buttons update the value
198 $this.find('.output-separator').click(function() {
199 $this.find('.output-separator').removeClass('active');
200 var txt = $(this).addClass('active').html();
201 $this.find('.output-separator-input').val( txt );
202 $this.find('.output-filename').val(function(i, v) {
203 // change filename extension based on separator
204 var filetype = (txt === 'json' || txt === 'array') ? 'js' :
205 txt === ',' ? 'csv' : 'txt';
206 return v.replace(/\.\w+$/, '.' + filetype);
207 });
208 return false;
209 });
210 $this.find('.output-quotes').click(function() {
211 $this.find('.output-quotes').removeClass('active');
212 $this.find('.output-replacequotes').val( $(this).addClass('active').text() );
213 return false;
214 });
215 // header/footer toggle buttons
216 $this.find('.output-header, .output-footer').click(function() {
217 $(this).toggleClass('active');
218 });
219 // clicking the download button; all you really need is to
220 // trigger an "output" event on the table
221 $this.find('.download').click(function() {
222 var typ,
223 $table = $this.find('table'),
224 wo = $table[0].config.widgetOptions,
225 val = $this.find('.output-filter-all :checked').attr('class');
226 wo.output_saveRows = val === 'output-filter' ? 'f' :
227 val === 'output-visible' ? 'v' :
228 // checked class name, see table.config.checkboxClass
229 val === 'output-selected' ? '.checked' :
230 val === 'output-sel-vis' ? '.checked:visible' :
231 'a';
232 val = $this.find('.output-download-popup :checked').attr('class');
233 wo.output_delivery = val === 'output-download' ? 'd' : 'p';
234 wo.output_separator = $this.find('.output-separator-input').val();
235 wo.output_replaceQuote = $this.find('.output-replacequotes').val();
236 wo.output_trimSpaces = $this.find('.output-trim').is(':checked');
237 wo.output_includeHTML = $this.find('.output-html').is(':checked');
238 wo.output_wrapQuotes = $this.find('.output-wrap').is(':checked');
239 wo.output_saveFileName = $this.find('.output-filename').val();
240
241 // first example buttons, second has radio buttons
242 if (groupIndex === 0) {
243 wo.output_includeHeader = $this.find('button.output-header').is(".active");
244 } else {
245 wo.output_includeHeader = !$this.find('.output-no-header').is(':checked');
246 wo.output_headerRows = $this.find('.output-headers').is(':checked');
247 }
248 // footer not included in second example
249 wo.output_includeFooter = $this.find('.output-footer').is(".active");
250
251 $table.trigger('outputTable');
252 return false;
253 });
254
255 // add tooltip
256 $this.find('.dropdown-menu [title]').tipsy({ gravity: 's' });
257
258 });
259
260 });</script>
261
262 </head>
263 <body>
264 <div id="banner">
265 <h1>table<em>sorter</em></h1>
266 <h2>Output Widget</h2>
267 <h3>Flexible client-side table sorting</h3>
268 <a href="index.html">Back to documentation</a>
269 </div>
270 <div id="main">
271
272 <p></p>
273 <br>
274
275 <div id="root" class="accordion">
276
277 <h3><a href="#">Notes</a></h3>
278 <div>
279
280 <h4>Changes</h4>
281 <ul>
282 <li>In <span class="version">v2.30.5</span>, the <a class="intlink" href="#output_formatcontent">output_formatContent</a> callback data parameter now includes the column index and parsed value for the cell.</li>
283 <li>In <span class="version">v2.29.0</span>, updated internal function parameters to make it easier to output all table data from the server without modifying the current table, or changing the pager size or page. See the modified <code>output_callback</code> code in the <a class="intlink" href="#setup_example_php">Output all data</a> section.</li>
284 <li>In <span class="version">v2.28.5</span>, triggering of the "outputTable" event multiple times in rapid succession (within 600 milliseconds) will now prevent the opening of multiple popups or cause mutliple downloads.</li>
285 <li>In <span class="version">v2.28.4</span>,
286 <ul>
287 <li>Added <a class="intlink" href="#output_includeheader"><code>output_includeHeader</code></a> option.</li>
288 <li>Added <a class="intlink" href="#output_saveplugin"><code>output_savePlugin</code></a> option.</li>
289 <li>Prevent javascript error while attempting to update an already open popup window.</li>
290 </ul>
291 </li>
292 <li>In <span class="version">v2.27.0</span>, the <a class="intlink" href="#output_callback"><code>output_callback</code></a> now includes a <code>url</code> parameter.</li>
293 </ul>
294
295 <div class="accordion start-closed">
296 <h3 id="old-notes"><a href="#">Older Notes</a></h3>
297 <div>
298 <ul>
299 <li>In <span class="version">v2.25.2</span>, updated the <a class="intlink" href="#output_saverows"><code>output_saveRows</code></a> option to accept a function.</li>
300 <li>In <span class="version">v2.25.1</span>, the <a class="intlink" href="#output_callback"><code>output_callback</code></a> can return modified data instead of a boolean.</li>
301 <li>In <span class="version">v2.22.4</span>, added <a class="intlink" href="#output_formatcontent"><code>output_formatContent</code></a> callback function which allows for extra formatting of cell content (e.g. convert <code>'&amp;amp;'</code> &rarr; <code>'&amp;'</code>).</li>
302 <li>In <span class="version">v2.22.2</span>,
303 <ul>
304 <li>The data-attribute used by the <code>output_dataAttrib</code> can now be an empty string.</li>
305 <li>Update <code>output_saveRows</code> option, it now includes the ability to set a jQuery filter selector.
306 <ul>
307 <li>For example, if you want to only output rows with an active checkbox, set this option to <code>'.checked'</code> (default class added by the checkbox parser contained in the "parser-input-select.js" file).</li>
308 <li>To output only visible active checkboxes, set this option to <code>'.checked:visible'</code>.</li>
309 <li>To output rows without an active checkbox, set this option to <code>':not(.checked)'</code>, etc.</li>
310 <li>More details can be found in the options section.</li>
311 </ul>
312 </li>
313 <li>Fix issue with <code>output_hiddenColumns</code> causing an empty output.</li>
314 </ul>
315 </li>
316 <li>In <span class="version">v2.22.0</span>,
317 <ul>
318 <li>Added the BOM back to the UTF-8 csv downloadable file to support unicode characters in Excel.</li>
319 <li>Add <code>output_hiddenColumns</code> which includes hidden columns in the output when <code>true</code>.</li>
320 </ul>
321 </li>
322 <li>In <span class="version">v2.21.0</span>, added the <code>output_includeFooter</code> option.</li>
323 <li>In <span class="version">v2.17.5</span>, the need to modify the server's content disposition no longer exists.</li>
324 <li>In <span class="version">v2.17.0</span>,
325 <ul>
326 <li>Added the <code>output_ignoreColumns</code> option &amp; modified the <a class="intlink" href="#output_callback"><code>output_callback</code></a> parameters.</li>
327 <li>Added <code>output_duplicateSpans</code> option to duplicate (when <code>true</code>) colspan &amp; rowspan content across cells.</li>
328 </ul>
329 </li>
330 <li>In <span class="version">v2.16.4</span>, added the <code>output_encoding</code> option.</li>
331 </ul>
332 </div>
333 </div>
334
335 <h4>Requirements</h4>
336 <ul>
337 <li>This widget will <strong>only work</strong> in tablesorter version 2.8+ and jQuery version 1.7+.</li>
338 <li><del>To download a file with the set filename and extension, the server's <code>Content-disposition</code> needs to be set</del></li>
339 <li>This widget now uses a method available in modern browsers (IE10+) to download files without the need for server side modifications</li>
340 <li>Support in older browsers (IE9 and older) have not been throughly tested.</li>
341 </ul>
342
343 <h4>Features &amp; Usage</h4>
344 <ul>
345 <li>This widget can output the table data to:
346 <ul>
347 <li>JSON</li>
348 <li>Array of arrays</li>
349 <li>Text with any separator (comma, tab, etc).</li>
350 </ul>
351 </li>
352 <li>Rowspan and colspan are supported by this widget. Please take note of additional information in the "Rowspan and colspan" section below.</li>
353 <li>Working with Excel:
354 <ul>
355 <li>To save a file for Excel
356 <ul>
357 <li>Set the <code>separator</code> to a comma (<code>,</code>).</li>
358 <li>Save the file with a <code>csv</code> extension, then load it into Excel.</li>
359 <li>Or, save the file with a <code>xls</code> extension; but when loading the file in Excel, you will likely see a message stating that the file is corrupt. Continue loading and you will see the expected data placed into each cell.</li>
360 <li><span class="label warning">Note</span> including a BOM in the <a class="intlink" href="#output_encoding"><code>output_encoding</code></a> option is no longer required!</li>
361 </ul>
362 </li>
363 <li>To copy the data into Excel
364 <ul>
365 <li>Set the <code>separator</code> as a tab (<code>\t</code>).</li>
366 <li>Open the data in a popup window, then copy the contents to the clipboard.</li>
367 <li>Paste from the clipboard directly into a cell in Excel.</li>
368 </ul>
369 </li>
370 </ul>
371 </li>
372 <li>This demo uses Bootstrap to create the download button dropdown for each table allowing the user to choose the settings
373 <ul>
374 <li>Using Bootstrap started out relatively difficult... any click inside would close the dropdown.</li>
375 <li>There are likely better alternatives as the download button and popup are all completely customizable.</li>
376 <li>The download dropdown code is overly complicated because it is set up for two tables &amp; allows modifying almost all of the options.</li>
377 <li>The only thing needed to output the table code (download or open a popup) is to trigger the following event after all of your widget options are set as desired: <pre class="prettyprint lang-js">$table.trigger('outputTable');</pre></li>
378 </ul>
379 </li>
380 </ul>
381 <h4>Known Issues</h4>
382 <ul>
383 <li>Some versions of Safari do not fully support direct downloading, nor will you be able to save the file with the set file name; for more details please refer to <a href="https://github.com/eligrey/FileSaver.js/issues/12">this issue</a>.</li>
384 </ul>
385 <h4>Credit</h4>
386 <ul>
387 <li>This widget uses heavily modified code from:
388 <ul>
389 <li><a href="http://www.kunalbabre.com/projects/table2CSV.php">HTML Table to CSV</a> (License unknown)</li>
390 <li><a href="https://github.com/PixelsCommander/Download-File-JS">Download-File-JS</a> (<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache v2.0</a>)</li>
391 <li><a href="http://html5-demos.appspot.com/static/a.download.html">Download demo</a> from <a href="https://github.com/ebidel/html5demos">ebidel/html5demos</a></li>
392 <li><a href="https://github.com/eligrey/FileSaver.js">FileSaver.js</a> (<a href="https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md">MIT</a>)</li>
393 </ul>
394 </li>
395 </ul>
396 </div>
397
398 <h3><a href="#">Basic Setup</a></h3>
399 <div>
400 Using the default settings of this widget will:
401 <ul>
402 <li>Output csv to a popup window.</li>
403 <li>Only include the last header row (if there are more than one rows).</li>
404 <li>Only include filtered rows (all rows will be included, even if the filter widget isn't being used).</li>
405 <li>Will only output the table cell text (ignoring any HTML).</li>
406 </ul>
407 Of course, all of the above behavior can be modified using the options.<br>
408 This is an example of how to setup a table using only the default settings:
409 <h4>HTML</h4>
410 <pre class="prettyprint lang-html">&lt;button class=&quot;download&quot;&gt;Get CSV&lt;/button&gt;
411 &lt;table class=&quot;tablesorter&quot;&gt;
412 &lt;!-- .... --&gt;
413 &lt;/table&gt;</pre>
414 <h4>Script</h4>
415 <pre class="prettyprint lang-js">$(function () {
416 var $table = $('table');
417
418 $('.download').click(function() {
419 // tell the output widget do it's thing
420 $table.trigger('outputTable');
421 });
422
423 $table.tablesorter({
424 theme: 'blue',
425 widgets: ['zebra', 'output']
426 });
427 });</pre>
428 Modification of the <code>.htaccess</code> is no longer required
429 <div class="ts-fade">
430 <h4>.htaccess</h4>
431 The Content-disposition headers <em>may need to be set</em> in order to make downloads work properly in IE. So <code>.htaccess</code> can look like:
432 <pre class="prettyprint lang-xml">&lt;FilesMatch "\.(?i:csv|txt)$"&gt;
433 ForceType application/octet-stream
434 Header set Content-Disposition attachment
435 &lt;/FilesMatch&gt;</pre>
436 </div>
437 </div>
438
439 <h3><a href="#">Setup Example (php)</a></h3>
440
441 <div>
442 <div class="accordion start-closed">
443 <h3><a href="#">Basic Example</a></h3>
444 <div>
445 Thanks to <a href="https://github.com/TheSin-">TheSin-</a> for sharing this setup which includes the necessary php to allow file download with the proper filename and extension (<a href="https://gist.github.com/TheSin-/3303c23f033bd973bf34">original Gist</a>)
446 <p></p>
447 <script src="https://gist.github.com/TheSin-/3303c23f033bd973bf34.js"></script>
448 </div>
449
450 <h3><a href="#">Output all data</a></h3>
451 <div>
452 This code example can be used in <span class="version updated">v2.29.0+</span> to load in all data to output it directly. It will not manipulate the data currently in the table.
453 <p></p>
454 <script src="https://gist.github.com/TheSin-/ce24a9b551ae3ebd8f4828bae7ea572d.js"></script>
455 </div>
456 </div>
457 </div>
458
459 <h3><a href="#">Rowspan and colspan</a></h3>
460 <div>
461 <ul>
462 <li>Even though tablesorter does not currently support <code>rowspan</code> and <code>colspan</code> within the tbody (except in child rows), this widget does support them.<br><br></li>
463 <li>When the widget encounters a <code>colspan</code>:
464 <ul>
465 <li>The colspan will be processed such that the data will be applied to each cell as if the colspan did not exist. So a header row that looks like this:
466 <pre class="prettyprint lang-html">&lt;th&gt;data&lt;/th&gt;&lt;th colspan="2"&gt;values&lt;/th&gt;</pre>
467 will produce an output like this:
468 <pre class="prettyprint lang-js">data, values, values</pre>
469 </li>
470 <li><span class="label label-info">Important</span> But, if a JSON output is chosen, the resulting object for a row cannot contain duplicate keys.<br>
471 <br>
472 <pre class="prettyprint lang-js">[{ "data" : "0", "values" : "1", "values" : "2" }]
473 // becomes [{ "data" : "0", "values" : "2" }]</pre>
474 So, in order to fix this, any key (header name) with a colspan will have the column index added to the end (see the <code>output_callbackJSON</code> option). So the same HTML above will produce the following output:
475 <pre class="prettyprint lang-js">[{ "data" : "0", "values" : "1", "values(2)" : "2" }]</pre>
476 </li>
477 </ul>
478 <br>
479 </li>
480 <li>When the widget encounters a <code>rowspan</code>:
481 <ul>
482 <li>The rowspan will be processed such that the data will be applied to each cell as if the rowspan did not exist. So if two header rows looks like this:
483 <pre class="prettyprint lang-html">&lt;tr&gt;
484 &lt;th rowspan=&quot;2&quot;&gt;line&lt;/th&gt;
485 &lt;th colspan=&quot;3&quot;&gt;values&lt;/th&gt;
486 &lt;/tr&gt;
487 &lt;tr&gt;
488 &lt;th&gt;value1&lt;/th&gt;
489 &lt;th&gt;value2&lt;/th&gt;
490 &lt;th&gt;value3&lt;/th&gt;
491 &lt;/tr&gt;</pre>
492 And the <code>output_headerRows</code> is <code>true</code>, the output will look like this:
493 <pre class="prettyprint lang-js">line,values,values,values
494 line,value1,value2,value3
495 1,1.1,1.2,1.3
496 1,1.4,1.5,1.5</pre>
497 </li>
498 <li>
499 <span class="label label-info">Important</span> But, if a JSON output is chosen, and <code>output_headerRows</code> is set to <code>false</code>, only header names from the last row will be applied to the output. The HTML above will produce this output:<br>
500 <br>
501 <pre class="prettyprint lang-js">[
502 { "line" : "1", "value1" : "1.1", "value2" : "1.2", "value3" : "1.3" },
503 { "line" : "1", "value1" : "1.4", "value2" : "1.5", "value3" : "1.5" }
504 ]</pre>
505 If the <code>output_headerRows</code> is set to <code>true</code>, the header names from the second row will be applied to alternating rows and the header with a <code>colspan</code> will get uniques names using the <code>output_callbackJSON</code> option. So the same HTML above will produce the following output:
506 <pre class="prettyprint lang-js">[
507 { "line" : "1", "values" : "1.1", "values(2)" : "1.2", "values(3)" : "1.3" },
508 { "line" : "1", "value1" : "1.4", "value2" : "1.5", "value3" : "1.5" }
509 ]</pre>
510 </li>
511 </ul>
512 </li>
513
514 </ul>
515 </div>
516
517 <h3><a href="#">Options</a></h3>
518 <div>
519 <h4>Output widget default options (added inside of tablesorter <code>widgetOptions</code>)</h4>
520 <div class="tip">
521 <span class="label label-info">TIP!</span> Click on the link in the option column to reveal full details (or <a href="#" class="toggleAll">toggle</a>|<a href="#" class="showAll">show</a>|<a href="#" class="hideAll">hide</a> all) or double click to update the browser location.
522 </div>
523 <br>
524 <table id="output-options" class="tablesorter-blue options">
525 <colgroup><col style="width:135px"><col style="width:100px"></colgroup>
526 <thead>
527 <tr><th>Option</th><th>Default</th><th class="sorter-false">Description</th></tr>
528 </thead>
529 <tbody>
530 <tr id="output_separator">
531 <td><a href="#" class="permalink">output_separator</a></td>
532 <td><code>','</code></td>
533 <td>
534 This option allows you to set the output as JSON, Array, or change the separator between cell data with text output:
535 <div class="collapsible">
536 <br>
537 When the output is created, and it this option doesn't match either <code>&quot;json&quot;</code> or <code>&quot;array&quot;</code>, each block of table cell data will be separated by this setting.<br>
538 <br>
539 This is the result with this option set to <code>&quot;,&quot;</code> and with the table filtered with Rank <button type="button" data-filter-column="1" data-filter-text=">100">&gt;100</button> :
540 <br>
541 <pre class="prettyprint lang-js">Rank,First,Last,Age,Total,Discount,Date
542 111,Peter,Parker,28,$9.99,20%,"Jul 6, 2006 8:14 AM"
543 166,Bruce Lee,Evans,22,$13.19,11%,"Jan 18, 2007 9:12 AM"</pre>
544 When this option is set to <code>&quot;array&quot;</code>, this will be the resulting output:
545 <pre class="prettyprint lang-js">[
546 [ "Rank", "First", "Last", "Age", "Total", "Discount", "Date" ],
547 [ "111", "Peter", "Parker", "28", "$9.99", "20%", "Jul 6, 2006 8:14 AM" ],
548 [ "166", "Bruce Lee", "Evans", "22", "$13.19", "11%", "Jan 18, 2007 9:12 AM" ],
549 ]</pre><span class="label label-info">Note</span> this requires <a href="http://caniuse.com/#feat=json"><code>JSON.stringify</code></a>, or the result will be a flattened array.<br>
550 <br>
551 And when this option is set to <code>&quot;json&quot;</code>, the resulting output will be a valid JSON format:<br>
552 <pre class="prettyprint lang-js">[
553 {
554 "Rank" : "111",
555 "First": "Peter",
556 "Last": "Parker",
557 "Age": "28",
558 "Total": "$9.99",
559 "Discount": "20%",
560 "Date": "Jul 6, 2006 8:14 AM"
561 }, {
562 "Rank": "166",
563 "First": "Bruce Lee",
564 "Last": "Evans",
565 "Age": "22",
566 "Total": "$13.19",
567 "Discount": "11%",
568 "Date": "Jan 18, 2007 9:12 AM"
569 }
570 ]</pre><span class="label label-info">Note</span> this also requires <a href="http://caniuse.com/#feat=json"><code>JSON.stringify</code></a>, or the result will show <code>[ [object Object], ... ]</code> in the output.
571 </div>
572 </td>
573 </tr>
574 <tr id="output_ignorecolumns">
575 <td><a href="#" class="permalink">output_ignoreColumns</a></td>
576 <td><code>[ ]</code></td>
577 <td>
578 Add the zero-based column index to this array to ignore specific columns (<span class="version">v2.17.0</span>)
579 <div class="collapsible">
580 <br>
581 For example, to use this option to hide the first column, set it as follows:
582 <pre class="prettyprint lang-js">output_ignoreColumns : [ 0 ]</pre>
583 <br>
584 <span class="label label-info">Note</span> This option will work properly with tables that contain rowspans &amp; colspans.
585 </div>
586 </td>
587 </tr>
588 <tr id="output_hiddencolumns">
589 <td><span class="permalink">output_hiddenColumns</span></td>
590 <td><code>false</code></td>
591 <td>
592 Include hidden columns (using <code>display: none</code>) in the output (<span class="version">v2.22.0</span>).
593 </td>
594 </tr>
595 <tr id="output_includefooter">
596 <td><span class="permalink">output_includeFooter</span></td>
597 <td><code>false</code></td>
598 <td>
599 Change this option to <code>true</code> to include the <code>&lt;tfoot&gt;</code> rows in the output (<span class="version">v2.21.0</span>)
600 </td>
601 </tr>
602 <tr id="output_includeheader">
603 <td><span class="permalink">output_includeHeader</span></td>
604 <td><code>true</code></td>
605 <td>
606 Change this option to <code>false</code> to not include any rows from the <code>&lt;thead&gt;</code> in the output (<span class="version">v2.28.4</span>)
607 </td>
608 </tr>
609 <tr id="output_headerrows">
610 <td><a href="#" class="permalink">output_headerRows</a></td>
611 <td><code>false</code></td>
612 <td>
613 Setting this option to <code>true</code> will include all header rows while processing a JSON output.
614 <div class="collapsible">
615 <br>
616 If this option is set to <code>false</code>, only the <strong>last row</strong> of the table header will be used as a key names for the tbody values; this does assume that the last table row in the header contains all of the header cell names &amp; does not contain any <code>colspan</code>.
617 </div>
618 </td>
619 </tr>
620 <tr id="output_dataattrib">
621 <td><a href="#" class="permalink">output_dataAttrib</a></td>
622 <td><code>'data-name'</code></td>
623 <td>
624 This option allows you to override any table cell (<code>thead</code> or <code>tbody</code>) text with the contents of this data-attribute (<span class="version updated">v2.22.2</span>)
625 <div class="collapsible">
626 <br>
627 <p>In the below example, the header text is obtained from this set data-attribute. If the data-attribute doesn't exist, then the header name is obtained from the actual header text.</p>
628 <p>The data-attribute can be an empty string (<span class="version updated">v2.22.2</span>).</p>
629 <pre class="prettyprint lang-html">&lt;thead&gt;
630 &lt;tr&gt;
631 &lt;th&gt;Rank&lt;/th&gt;
632 &lt;th data-name=&quot;First&quot;&gt;First Name&lt;/th&gt;
633 &lt;th data-name=&quot;Last&quot;&gt;Last Name&lt;/th&gt;
634 &lt;th&gt;Age&lt;/th&gt;
635 &lt;th&gt;Total&lt;/th&gt;
636 &lt;th&gt;Discount&lt;/th&gt;
637 &lt;th&gt;Date&lt;/th&gt;
638 &lt;/tr&gt;
639 &lt;/thead&gt;</pre>
640 <p>Notice in this output that the "First" and "Last" columns match the contents of the <code>data-name</code> attribute and not the header text:</p>
641 <pre class="prettyprint lang-js">Rank,First,Last,Age,Total,Discount,Date</pre>
642 <span class="label warning">* NOTE *</span> The core plugin uses the <code>data-text</code> attribute for text extraction. If you want to use the same data for both, make the data-attributes match!
643 </div>
644 </td>
645 </tr>
646 <tr id="output_delivery">
647 <td><a href="#" class="permalink">output_delivery</a></td>
648 <td><code>'popup'</code></td>
649 <td>
650 Change this option to either <code>'popup'</code> or <code>'download'</code> to set the destination of the output.
651 <div class="collapsible">
652 <br>
653 When setting this option, only the first letter is required (<code>'p'</code> or <code>'d'</code>) :
654 <br>
655 <pre class="prettyprint lang-js">output_delivery : 'p'</pre>
656 </div>
657 </td>
658 </tr>
659 <tr id="output_saverows">
660 <td><a href="#" class="permalink">output_saveRows</a></td>
661 <td><code>'filtered'</code></td>
662 <td>
663 Change this option to either <code>'filtered'</code>, <code>'visible'</code>, <code>'all'</code>, a jQuery filter selector (<span class="version updated">v2.25.1</span>) to set to match rows to be added to the output, or a jQuery filter callback function (<span class="version updated">v2.25.2</span>).
664 <div class="collapsible">
665 <br>
666 <ul>
667 <li><code>'filtered'</code> - output rows that have not been filtered by the filter widget (i.e. rows that do not have the "filtered" class applied; this class name is set by the <a href="index.html#widget-filter-filteredrow"><code>filter_filteredRow</code> widget option</a>).</li>
668 <li><code>'visible'</code> - only output rows that are currently visible; rows hidden by pagination will not be included.</li>
669 <li>jQuery filter selector - output all rows that match the jQuery filter (use a string; not a jQuery object).
670 <ul>
671 <li>For example, <code>'.checked'</code>, <code>'.checked:visible'</code> or <code>:not(.checked)</code> can be used; these examples match the class set by the checkbox parser <code>table.config.checkboxClass</code> class setting.</li>
672 <li>For reference, internally, the rows are filtered using this setting: <code>$rows.filter( wo.output_saveRows )</code>.</li>
673 <li>Instead of checking to see if <code>output_saveRows</code> works as a filter, the option is checked to see if it <em>starts</em> with any of the following characters before it is used as a filter:
674 <ul>
675 <li><code>'.'</code> (class selector)</li>
676 <li><code>'#'</code> (id selector)</li>
677 <li><code>':'</code> (filter selectors, e.g. <code>':visible'</code> or <code>':not()'</code>)</li>
678 <li><code>[</code> (start of an attribute selector)</li>
679 </ul>
680 </li>
681 </ul>
682 </li>
683 <li><code>'all'</code> - output all rows even if they are hidden. When the pager <code>removeRows</code> option is <code>true</code>, rows not visible do not exist in the DOM and therefore will not be included.</li>
684 <li><code>function</code> - (<span class="version updated">v2.25.2</span>) Include a <a href="http://api.jquery.com/filter/#filter-function">filter function</a> to test each row and return a boolean value; <code>true</code> to include the row, and <code>false</code> to exclude. For example:
685 <pre class="prettyprint lang-js">output_saveRows: function(index, element) {
686 // "this" is the same as "element"
687 // only include the row if the select element's value is set to "include".
688 return $(this).find('select').val() === 'include';
689 }</pre></li>
690 </ul>
691 <p>Even if this option is set to <code>'filtered'</code> and the filter widget is not being used, all of the rows will be added to the output.</p>
692 <p><span class="label label-info">*NOTE*</span> When setting this option,</p>
693 <ul>
694 <li>Only the first letter is required for filtered (<code>'f'</code>) or visible (<code>'v'</code>) rows.
695 <pre class="prettyprint lang-js">output_saveRows : 'f'</pre>
696 </li>
697 <li>If using a jQuery selector, it won't be recognized as a selector unless one of the characters (<code>.#:[</code>) is at the start of the string; if your filter is not working, or uses a charater not listed, then use the callback function, or you can <a href="index.html#Support">contact me for support</a>.</li>
698 <li>If no matches are found, all rows will be sent to the output.</li>
699 </ul>
700 </div>
701 </td>
702 </tr>
703 <tr id="output_duplicatespans">
704 <td><a href="#" class="permalink">output_duplicateSpans</a></td>
705 <td><code>true</code></td>
706 <td>
707 When <code>true</code>, colspan &amp; rowspan content is duplicated in the output
708 <div class="collapsible">
709 <br>
710 By default, any <em>tbody</em> cells that are included in the colspan or rowspan will have the cell's content duplicated in the output. When set to <code>false</code>, the cells within the colspan or rowspan will be empty.<br>
711 Here is an example of the second table output with this option set to <code>false</code>:
712 <pre class="prettyprint lang-js">line,values,values,values
713 line,value1,value2,value3
714 1,1.1,1.2,1.3
715 ,1.4,1.5,
716 2,2.1,2.2,2.3
717 ,2.4,2.5,
718 3,3.1,3.2,3.3
719 ,3.4,3.5,
720 4,4.1,,4.2
721 ,,,4.3</pre>This option does not affect thead cells, they will always have duplicated content.
722 </div>
723 </td>
724 </tr>
725 <tr id="output_replacequote">
726 <td><a href="#" class="permalink">output_replaceQuote</a></td>
727 <td><code>'\u201c;'</code></td>
728 <td>
729 When a table cell contains a quote, it needs to be modified to differentiate it from cell content that is wrapped in quotes.
730 <div class="collapsible">
731 <br>
732 Quotes are necessary to maintain the integrity of the output data when any cell content contains either the separator or carriage returns. In order to do this, this widget replaces any quotes within cell content with this character.<br>
733 <br>
734 By default, this replacement character is a left double quote (<code>&#x201c;</code>, shown as it's unicode equivalent <code>'\u201c;'</code>).
735 <pre class="prettyprint lang-js">output_replaceQuote : '\u201c;' // left double quote</pre>
736 In the demo below, additional examples of a single quote (<code>'</code>) and escaped double quote (<code>\"</code>) are added as selectable buttons.
737
738 <pre class="prettyprint lang-js">Rank,First,Last,Age,Total,Discount,Date
739 1,Philip Aaron Wong,Johnson Sr Esq,25,$5.95,22%,"Jun 26, 2004 7:22 AM"
740 21,John,“Robin“\n\tHood,33,$19.99,25%,"Dec 10, 2002 5:14 AM"
741 013,Clark,“Old man“ Kent Sr.,18,$15.89,44%,"Jan 12, 2003 11:14 AM"
742 16,Jim,“Jimmy“ Franco,24,-$14.19,24%,"Jan 14, 2004 11:23 AM"
743 55,Dennis,“Charley“ Bronson,65,$123.00,32%,"Jan 20, 2001 1:12 PM"</pre>
744 </div>
745 </td>
746 </tr>
747 <tr id="output_includehtml">
748 <td><a href="#" class="permalink">output_includeHTML</a></td>
749 <td><code>false</code></td>
750 <td>
751 This option, if <code>true</code> tells the widget to include any HTML within the table cells.
752 <div class="collapsible">
753 <br>
754 Only cells within the table body will include HTML. The table header has a lot of extra markup for the sorting arrows, so it is automatically stripped of HTML.
755 </div>
756 </td>
757 </tr>
758 <tr id="output_trimspaces">
759 <td><a href="#" class="permalink">output_trimSpaces</a></td>
760 <td><code>true</code></td>
761 <td>
762 This option, if <code>true</code> tells the widget to remove any leading and trailing (white)space characters
763 <div class="collapsible">
764 <br>
765 Leading and trailing whitespace characters include newlines, spaces, non-breaking spaces and tabs. Any of these whitespace characters in the middle of the table cell will always be preserved.<br>
766 <br>
767 <span class="label label-info">*NOTE*</span> carriage returns in the middle of the table cell content <em>will be stripped out</em> if this option is set to <code>true</code>.
768 </div>
769 </td>
770 </tr>
771 <tr id="output_wrapquotes">
772 <td><a href="#" class="permalink">output_wrapQuotes</a></td>
773 <td><code>false</code></td>
774 <td>
775 This option, if <code>true</code> wrap the output of all table cell content in quotes.
776 <div class="collapsible">
777 <br>
778 This is the output of the widget when the age column is filtered for results in the range <button type="button" data-filter-column="4" data-filter-text="25 - 35">25 - 35</button>.
779 <pre class="prettyprint lang-js">"Rank","First","Last","Age","Total","Discount","Date"
780 "1","Philip Aaron Wong","Johnson Sr Esq","25","$5.95","22%","Jun 26, 2004 7:22 AM"
781 "111","Peter","Parker","28","$9.99","20%","Jul 6, 2006 8:14 AM"
782 "21","John","'Robin'\n\tHood","33","$19.99","25%","Dec 10, 2002 5:14 AM"
783 "9","Martha","delFuego","25","$22.09","12%","Jun 11, 2011 10:55 AM"</pre>
784 Notice that every block of data is wrapped in a quote. When this option is <code>false</code>, only blocks that contain a newline or separator (comma, by default) will be wrapped in quotes. Here is the same data set without this option set:
785 <pre class="prettyprint lang-js">Rank,First,Last,Age,Total,Discount,Date
786 1,Philip Aaron Wong,Johnson Sr Esq,25,$5.95,22%,"Jun 26, 2004 7:22 AM"
787 111,Peter,Parker,28,$9.99,20%,"Jul 6, 2006 8:14 AM"
788 21,John,'Robin'\n\tHood,33,$19.99,25%,"Dec 10, 2002 5:14 AM"
789 9,Martha,delFuego,25,$22.09,12%,"Jun 11, 2011 10:55 AM"</pre>
790 Only the dates, which contain commas, are wrapped in quotes.
791 </div>
792 </td>
793 </tr>
794 <tr id="output_popupstyle">
795 <td><a href="#" class="permalink">output_popupStyle</a></td>
796 <td><code>'width=500,height=300'</code></td>
797 <td>If the data is sent to a popup window, the features set by this option are applied (do not include any spaces).
798 <div class="collapsible">
799 <br>
800 Set the desired popup window features within this string. For a full list of features, please refer to the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window.open">Mozilla Developer Network: Window.open</a> documentation page (look for <code>strWindowFeatures</code> parameters).<br>
801 <br>
802 The <code>&lt;textarea&gt;</code> within the popup window is set with 100% width and height.
803 </div>
804 </td>
805 </tr>
806 <tr id="output_savefilename">
807 <td><span class="permalink">output_saveFileName</span></td>
808 <td><code>'mytable.csv'</code></td>
809 <td>When downloading, this option sets the filename of the output.</td>
810 </tr>
811 <tr id="output_formatcontent">
812 <td><a href="#" class="permalink">output_formatContent</a></td>
813 <td>null</td>
814 <td>This callback is executed after the content of a table cell has been processed (<span class="version">v2.22.4</span>; <span class="version updated">2.30.5</span>).
815 <div class="collapsible">
816 <br>
817 Default setting &amp; how to use this option:
818 <pre class="prettyprint lang-js">output_formatContent : function( c, wo, data ) {
819 // data.isHeader (boolean) = true if processing a header cell
820 // data.$cell = jQuery object of the cell currently being processed
821 // data.content = processed cell content (spaces trimmed, quotes added/replaced, etc)
822 // data.columnIndex = column in which the cell is contained (added v2.30.5)
823 // data.parsed = cell content parsed by the associated column parser (added v2.30.5)
824 // **********
825 // use data.$cell.html() to get the original cell content
826 return data.content
827 .replace(/fred/ig, '') // because we don't like fred
828 // because HTML is being processed, you might want to also replace HTML codes
829 .replace(/&amp;amp;/g, '&') // convert '&amp;amp;' &rarr; '&amp;'
830 }</pre>
831 If you want to replace all HTML codes, check out the <a href="https://github.com/mathiasbynens/he#hedecodehtml-options">he library</a>; then you can use this code (Fred would be happy):
832 <pre class="prettyprint lang-js">output_formatContent : function( c, wo, data ) {
833 // replace all HTML shortcut codes
834 // (e.g. 'foo &amp;copy; bar &amp;ne; baz &amp;#x1D306; qux' &rarr; 'foo &copy; bar &ne; baz &#x1D306; qux' )
835 return he.decode( data.content );
836 }</pre>
837 </div>
838 </td>
839 </tr>
840
841 <tr id="output_callback">
842 <td><a href="#" class="permalink">output_callback</a></td>
843 <td>{see description}</td>
844 <td>Return <code>true</code> or modified data in this callback to continue the download or open the popup (<span class="version updated">v2.25.1</span>).
845 <div class="collapsible">
846 <br>
847 <p>In <span class="version">v2.27.0</span>, a url parameter was added to the callback.</p>
848 <p>In <span class="version">v2.25.1</span>, this callback can return modified data for output.</p>
849 <p>As of v2.17.0 (<span class="version updated">v2.27.0</span>) , the callback function was modified to pass <del>two</del> three parameters:</p>
850 <ul>
851 <li><code>config</code> - the <code>table.config</code> settings.</li>
852 <li><code>data</code> - the output data as a string</li>
853 <li><code>url</code> - the url of the current page (including filters, sort, etc), if the pager widget/addon is being used.
854 <ul>
855 <li>You can get the same value by using <code>config.pager.ajaxObject.url</code>; this parameter was added for convenience.</li>
856 <li>The value will be <code>null</code> if the pager is not being used.</li>
857 </ul>
858 </li>
859 </ul>
860 Default setting:
861 <pre class="prettyprint lang-js">function(config, data, url) {
862 // return data.replace( /Mary Smith/g, 'Mary Smith-Jones' ); // v2.25.1+
863 return true;
864 }</pre>
865 After table processing has completed, this callback function is exectued. If <code>true</code> is not returned, the processed data will not open a popup, nor download the data.
866 <pre class="prettyprint lang-js">output_callback : function(config, data, url) {
867 // send output to the console only
868 console.log(data);
869 return false;
870 }</pre>
871 If you are using the pager and want to provide the entire table in the output, use this callback as follows:
872 <pre class="prettyprint lang-js">function(config, data, url) {
873 // This is only an example, but you could set it up so that a "&csv=1"
874 // parameter in the url to signal the server to provide the csv for the
875 // entire table using the current filters, sort, etc.
876 if (url) {
877 return $.getJSON(url + "&csv=1")
878 .done(function(data) {
879 return data.csv;
880 })
881 .fail(function() {
882 alert('no go on CSV');
883 return false;
884 });
885 }
886 return true;
887 }</pre>
888 </div>
889 </td>
890 </tr>
891
892 <tr id="output_callbackjson">
893 <td><a href="#" class="permalink">output_callbackJSON</a></td>
894 <td>{see description}</td>
895 <td>JSON callback executed when a colspan is encountered in the header.
896 <div class="collapsible">
897 <br>
898 Default setting &amp; how to use this option:
899 <pre class="prettyprint lang-js">output_callbackJSON : function($cell, txt, cellIndex) {
900 return txt + '(' + (cellIndex + col) + ')';
901 }</pre>For more details on why this option is necessary, see the "Rowspan and colspan" section above.
902 </div>
903 </td>
904 </tr>
905
906 <tr id="output_encoding">
907 <td><a href="#" class="permalink">output_encoding</a></td>
908 <td>{see description}</td>
909 <td>Default encoding setting (<span class="version">2.16.4</span>; <span class="version updated">2.17.5</span>)
910 <div class="collapsible">
911 <br>
912 As of <span class="version updated">2.17.5</span>, this option no longer needs to be modified to specifically make this widget download files that will work in Excel.<br>
913 <br>
914 The method used to download has been completely changed. The downloads still need an encoding setting, but this option is now set to a default of
915 <pre class="prettyprint lang-js">output_encoding : 'data:application/octet-stream;charset=utf8,'</pre>
916 <span class="label warning">Note</span> The trailing comma is important!
917 <hr>
918 The information below is no longer relavant:
919 <div class="ts-fade">
920 With the default settings (utf-8 no BOM), Excel does not properly encode accented characters unless the csv file is imported. Depending on the characters used, there are various methods which will allow proper encoding, but no one method is ideal. So this option can be set to allow the user to try different encodings. Set it as follows:
921 <pre class="prettyprint lang-js">// output data type (with BOM or Windows-1252 is needed for excel)
922 // NO BOM : 'data:text/csv;charset=utf8,'
923 // With BOM : 'data:text/csv;charset=utf8,%EF%BB%BF'
924 // WIN 1252 : 'data:text/csv;charset=windows-1252,' // ANSI (subset of ISO-8859-1)
925 output_encoding : 'data:text/csv;charset=utf8,'</pre>
926 </div>
927 </div>
928 </td>
929 </tr>
930
931 <tr id="output_saveplugin">
932 <td><a href="#" class="permalink">output_savePlugin</a></td>
933 <td><code>null</code></td>
934 <td>Override internal save file code and use an external plugin (<span class="version">v2.28.4</span>)
935 <div class="collapsible">
936 <br>
937 <p>You can use a plugin such as <a href="https://github.com/eligrey/FileSaver.js">FileSaver.js</a> instead of the simplified, and possibly out-of-date internal method.</p>
938 Use this option as follows:
939 <pre class="prettyprint lang-js">output_savePlugin: function(config, widgetOptions, data) {
940 var blob = new Blob([data], {type: widgetOptions.output_encoding});
941 saveAs(blob, widgetOptions.output_saveFileName);
942 }</pre>
943 </div>
944 </td>
945 </tr>
946
947 </tbody>
948 </table>
949 <span class="label label-info">Note</span> If you need to change the carriage return and/or the tab replacement strings, modify them as follows (changed in <span class="version">v2.21.2</span>):
950 <blockquote>
951 <pre class="prettyprint lang-js">// these are the default settings
952 $.tablesorter.output.replaceCR = '\x0d\x0a';
953 $.tablesorter.output.replaceTab = '\x09';</pre>
954 </blockquote>
955 </div>
956
957 </div>
958
959 <p></p>
960
961 <h1>Demo</h1>
962 <br>
963 Search <button type="button" data-filter-column="6" data-filter-text=">15">&gt;15</button> in the Discount column<br>
964 <br>
965
966 <div id="demo"><div class="group1">
967 <h4>Table showing filter &amp; pager support</h4>
968 <div class="btn-group">
969 <button type="button" class="btn btn-default reset">Reset</button> <!-- targeted by the "filter_reset" option -->
970
971 <!-- Split button -->
972 <div class="btn-group">
973 <button type="button" class="btn btn-default download">Output</button>
974 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
975 <span class="caret"></span>
976 <span class="sr-only">Toggle Dropdown</span>
977 </button>
978 <ul class="dropdown-menu" role="menu">
979 <li><h5><strong>Output options</strong></h5></li>
980 <li>
981 <label>Separator: <input class="output-separator-input" type="text" size="2" value="," /></label>
982 <button type="button" class="output-separator btn btn-default btn-xs active" title="comma">,</button>
983 <button type="button" class="output-separator btn btn-default btn-xs" title="semi-colon">;</button>
984 <button type="button" class="output-separator btn btn-default btn-xs" title="tab">&#x21e5;</button>
985 <button type="button" class="output-separator btn btn-default btn-xs" title="space">&#x2423;</button>
986 <button type="button" class="output-separator btn btn-default btn-xs" title="output JSON">json</button>
987 <button type="button" class="output-separator btn btn-default btn-xs" title="output Array (see note)">array</button>
988 </li>
989 <li>
990 <label>Send to:</label>
991 <div class="btn-group output-download-popup" data-toggle="buttons" title="Download file or open in Popup window">
992 <label class="btn btn-default btn-sm active">
993 <input type="radio" name="delivery1" class="output-popup" checked> Popup
994 </label>
995 <label class="btn btn-default btn-sm">
996 <input type="radio" name="delivery1" class="output-download"> Download
997 </label>
998 </div>
999 </li>
1000 <li>
1001 <label>Include:</label>
1002 <div class="btn-group output-filter-all" data-toggle="buttons" title="Output only filtered, visible, selected, selected+visible or all rows">
1003 <label class="btn btn-default btn-sm active">
1004 <input type="radio" name="getrows1" class="output-filter" checked="checked"> Filtered
1005 </label>
1006 <label class="btn btn-default btn-sm">
1007 <input type="radio" name="getrows1" class="output-visible"> Visible
1008 </label>
1009 <label class="btn btn-default btn-sm">
1010 <input type="radio" name="getrows1" class="output-selected"> Selected
1011 </label>
1012 <label class="btn btn-default btn-sm">
1013 <input type="radio" name="getrows1" class="output-sel-vis"> Sel+Vis
1014 </label>
1015 <label class="btn btn-default btn-sm">
1016 <input type="radio" name="getrows1" class="output-all"> All
1017 </label>
1018 </div>
1019 </li>
1020 <li>
1021 <button class="output-header btn btn-default btn-sm active" title="Include table header">Header</button>
1022 <button class="output-footer btn btn-default btn-sm active" title="Include table footer">Footer</button>
1023 </li>
1024 <li class="divider"></li>
1025 <li>
1026 <label>Replace quotes: <input class="output-replacequotes" type="text" size="2" value="'" /></label>
1027 <button type="button" class="output-quotes btn btn-default btn-xs active" title="single quote">'</button>
1028 <button type="button" class="output-quotes btn btn-default btn-xs" title="left double quote">&#x201c;</button>
1029 <button type="button" class="output-quotes btn btn-default btn-xs" title="escaped quote">\"</button>
1030 </li>
1031 <li><label title="Remove extra white space from each cell">Trim spaces: <input class="output-trim" type="checkbox" checked /></label></li>
1032 <li><label title="Include HTML from cells in output">Include HTML: <input class="output-html" type="checkbox" /></label></li>
1033 <li><label title="Wrap all values in quotes">Wrap in Quotes: <input class="output-wrap" type="checkbox" /></label></li>
1034 <li><label title="Choose a download filename">Filename: <input class="output-filename" type="text" size="15" value="mytable.csv"/></label></li>
1035 </ul>
1036 </div>
1037 </div>
1038
1039 <div class="ts-pager form-horizontal">
1040 <button type="button" class="btn btn-default btn-sm first"><i class="glyphicon glyphicon-step-backward"></i></button>
1041 <button type="button" class="btn btn-default btn-sm prev"><i class="glyphicon glyphicon-backward"></i></button>
1042 <span class="pagedisplay"></span> <!-- this can be any element, including an input -->
1043 <button type="button" class="btn btn-default btn-sm next"><i class="glyphicon glyphicon-forward"></i></button>
1044 <button type="button" class="btn btn-default btn-sm last"><i class="glyphicon glyphicon-step-forward"></i></button>
1045 <select class="pagesize form-control btn-sm" title="Select page size">
1046 <option selected="selected" value="5">5</option>
1047 <option value="10">10</option>
1048 </select>
1049 <select class="gotoPage form-control btn-sm" title="Select page number"></select>
1050 </div>
1051
1052 <table id="table" class="tablesorter">
1053 <thead>
1054 <tr>
1055 <th class="sorter-checkbox filter-false">&nbsp;</th>
1056 <th>Rank</th>
1057 <th data-name="First">First Name</th>
1058 <th data-name="Last">Last Name</th>
1059 <th>Age</th>
1060 <th>Total</th>
1061 <th>Discount</th>
1062 <th>Date</th>
1063 </tr>
1064 </thead>
1065 <tfoot>
1066 <tr>
1067 <th></th>
1068 <th>Rank</th>
1069 <th data-name="First & middle">First Name</th>
1070 <th data-name="Last & Title">Last Name</th>
1071 <th>Age</th>
1072 <th>Total</th>
1073 <th>Discount</th>
1074 <th>Date</th>
1075 </tr>
1076 </tfoot>
1077 <tbody>
1078 <tr><td><input type="checkbox"></td><td>1</td><td>Philip Aaron Wong</td><td>Johnson Sr Esq</td><td>25</td><td>$5.95</td><td>22%</td><td>Jun 26, 2004 7:22 AM</td></tr>
1079 <tr><td><input type="checkbox"></td><td>11</td><td>Aaron</td><td>"doc" Hibert</td><td>12</td><td>$2.99</td><td>5%</td><td>Aug 21, 2009 12:21 PM</td></tr>
1080 <tr><td><input type="checkbox"></td><td>12</td><td>Brandon Clark</td><td>Henry Jr</td><td>51</td><td>$42.29</td><td>18%</td><td>Oct 13, 2000 1:15 PM</td></tr>
1081 <tr><td><input type="checkbox"></td><td>111</td><td>Peter</td><td>Parker</td><td>28</td><td>$9.99</td><td>20%</td><td>Jul 6, 2006 8:14 AM</td></tr>
1082 <tr><td><input type="checkbox"></td><td>21</td><td><span class="red">John</span></td><td> "Robin"<br> Hood </td><td>33</td><td>$19.99</td><td>25%</td><td>Dec 10, 2002 5:14 AM</td></tr>
1083 <tr><td><input type="checkbox"></td><td>013</td><td>Clark</td><td>"Old man" Kent Sr.</td><td>18</td><td>$15.89</td><td>44%</td><td>Jan 12, 2003 11:14 AM</td></tr>
1084 <tr><td><input type="checkbox"></td><td>005</td><td>Bruce</td><td>Almighty <span class="red">Esq</span></td><td>45</td><td>$153.19</td><td>44%</td><td>Jan 18, 2021 9:12 AM</td></tr>
1085 <tr><td><input type="checkbox"></td><td>10</td><td>Alex</td><td>Dumass</td><td>13</td><td>$5.29</td><td>4%</td><td>Jan 8, 2012 5:11 PM</td></tr>
1086 <tr><td><input type="checkbox"></td><td>16</td><td>Jim</td><td>"Jimmy" Franco</td><td>24</td><td><span class="red">-$14.19</span></td><td>24%</td><td>Jan 14, 2004 11:23 AM</td></tr>
1087 <tr><td><input type="checkbox"></td><td>166</td><td>Bruce Lee</td><td>Evans</td><td>22</td><td>$13.19</td><td>11%</td><td>Jan 18, 2007 9:12 AM</td></tr>
1088 <tr><td><input type="checkbox"></td><td>100</td><td>Brenda Dexter</td><td>McMasters</td><td>18</td><td>$55.20</td><td>15%</td><td>Feb 12, 2010 7:23 PM</td></tr>
1089 <tr><td><input type="checkbox"></td><td>55</td><td>Dennis</td><td><span class="red">"Charley"</span> Bronson</td><td>65</td><td>$123.00</td><td>32%</td><td>Jan 20, 2001 1:12 PM</td></tr>
1090 <tr><td><input type="checkbox"></td><td>9</td><td>Martha</td><td>delFuego</td><td>25</td><td>$22.09</td><td>12%</td><td>Jun 11, 2011 10:55 AM</td></tr>
1091 </tbody>
1092 </table>
1093 </div>
1094
1095 <div class="group2">
1096 <h4>Table showing output widget rowspan &amp; colspan support</h4>
1097 <div class="btn-group">
1098 <button type="button" class="btn btn-default reset">Reset</button> <!-- targeted by the "filter_reset" option -->
1099
1100 <!-- Split button -->
1101 <div class="btn-group">
1102 <button type="button" class="btn btn-default download">Output</button>
1103 <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
1104 <span class="caret"></span>
1105 <span class="sr-only">Toggle Dropdown</span>
1106 </button>
1107 <ul class="dropdown-menu" role="menu">
1108 <li><h5><strong>Output options</strong></h5></li>
1109 <li>
1110 <label>Separator: <input class="output-separator-input" type="text" size="2" value="," /></label>
1111 <button type="button" class="output-separator btn btn-default btn-xs active" title="comma">,</button>
1112 <button type="button" class="output-separator btn btn-default btn-xs" title="semi-colon">;</button>
1113 <button type="button" class="output-separator btn btn-default btn-xs" title="tab">&#x21e5;</button>
1114 <button type="button" class="output-separator btn btn-default btn-xs" title="space">&#x2423;</button>
1115 <button type="button" class="output-separator btn btn-default btn-xs" title="output JSON">json</button>
1116 <button type="button" class="output-separator btn btn-default btn-xs" title="output Array (see note)">array</button>
1117 </li>
1118 <li>
1119 <label>Send to:</label>
1120 <div class="btn-group output-download-popup" data-toggle="buttons" title="Download file or open in Popup window">
1121 <label class="btn btn-default btn-sm active">
1122 <input type="radio" name="delivery2" class="output-popup" checked> Popup
1123 </label>
1124 <label class="btn btn-default btn-sm">
1125 <input type="radio" name="delivery2" class="output-download"> Download
1126 </label>
1127 </div>
1128 </li>
1129 <li>
1130 <label>Include:</label>
1131 <div class="btn-group output-filter-all" data-toggle="buttons" title="Output only filtered, visible or all rows">
1132 <label class="btn btn-default btn-sm active">
1133 <input type="radio" name="getrows2" class="output-filter" checked> Filtered
1134 </label>
1135 <label class="btn btn-default btn-sm">
1136 <input type="radio" name="getrows2" class="output-visible"> Visible
1137 </label>
1138 <label class="btn btn-default btn-sm">
1139 <input type="radio" name="getrows2" class="output-all"> All
1140 </label>
1141 </div>
1142 </li>
1143 <li>
1144 <label>Header:</label>
1145 <div class="btn-group output-includes" data-toggle="buttons" title="Include no, single (last row), or all table headers">
1146 <label class="btn btn-default btn-sm">
1147 <input type="radio" name="headers" class="output-no-header"> None
1148 </label>
1149 <label class="btn btn-default btn-sm">
1150 <input type="radio" name="headers"> Single
1151 </label>
1152 <label class="btn btn-default btn-sm active">
1153 <input type="radio" name="headers" class="output-headers" checked> All
1154 </label>
1155 </div>
1156 </li>
1157 <li class="divider"></li>
1158 <li>
1159 <label>Replace quotes: <input class="output-replacequotes" type="text" size="2" value="'" /></label>
1160 <button type="button" class="output-quotes btn btn-default btn-xs active" title="single quote">'</button>
1161 <button type="button" class="output-quotes btn btn-default btn-xs" title="left double quote">&#x201c;</button>
1162 <button type="button" class="output-quotes btn btn-default btn-xs" title="escaped quote">\"</button>
1163 </li>
1164 <li><label title="Remove extra white space from each cell">Trim spaces: <input class="output-trim" type="checkbox" checked /></label></li>
1165 <li><label title="Include HTML from cells in output">Include HTML: <input class="output-html" type="checkbox" /></label></li>
1166 <li><label title="Wrap all values in quotes">Wrap in Quotes: <input class="output-wrap" type="checkbox" /></label></li>
1167 <li><label title="Choose a download filename">Filename: <input class="output-filename" type="text" size="15" value="mytable.csv"/></label></li>
1168 </ul>
1169 </div>
1170
1171 </div>
1172
1173 <table id="table2">
1174 <thead>
1175 <tr>
1176 <th rowspan="2">line</th>
1177 <th colspan="3">values</th>
1178 </tr>
1179 <tr>
1180 <th>value1</th>
1181 <th>value2</th>
1182 <th>value3</th>
1183 </tr>
1184 </thead>
1185 <tbody>
1186 <tr>
1187 <td rowspan="2">1</td>
1188 <td>1.1</td>
1189 <td>1.2</td>
1190 <td><span class="red">1.3</span></td>
1191 </tr>
1192 <tr class="tablesorter-childRow">
1193 <td>1.4</td>
1194 <td colspan="2">1.5</td>
1195 </tr>
1196 <tr>
1197 <td rowspan="2">2</td>
1198 <td>2.1</td>
1199 <td><span class="red">2.2</span></td>
1200 <td>2.3</td>
1201 </tr>
1202 <tr class="tablesorter-childRow">
1203 <td>2.4</td>
1204 <td colspan="2">2.5</td>
1205 </tr>
1206 <tr>
1207 <td rowspan="2">3</td>
1208 <td>3.1</td>
1209 <td>3.2</td>
1210 <td>3.3</td>
1211 </tr>
1212 <tr class="tablesorter-childRow">
1213 <td>3.4</td>
1214 <td colspan="2"><span class="red">3.5</span></td>
1215 </tr>
1216 <tr>
1217 <td rowspan="2">4</td>
1218 <td rowspan="2" colspan="2"><span class="red">4.1</span></td>
1219 <td>4.2</td>
1220 </tr>
1221 <tr class="tablesorter-childRow">
1222 <td>4.3</td>
1223 </tr>
1224 </tbody>
1225 </table>
1226 </div>
1227 </div>
1228
1229 <h1>Page Header</h1>
1230 <div>
1231 <pre class="prettyprint lang-html">&lt;!-- Tablesorter: required --&gt;
1232 &lt;link href=&quot;css/theme.bootstrap.css&quot; rel=&quot;stylesheet&quot;&gt;
1233 &lt;script src=&quot;js/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
1234 &lt;script src=&quot;js/jquery.tablesorter.js&quot;&gt;&lt;/script&gt;
1235 &lt;script src=&quot;js/jquery.tablesorter.widgets.js&quot;&gt;&lt;/script&gt;
1236 &lt;!-- pager --&gt;
1237 &lt;link href=&quot;css/jquery.tablesorter.pager.css&quot; rel=&quot;stylesheet&quot;&gt;
1238 &lt;script src=&quot;js/jquery.tablesorter.pager.js&quot;&gt;&lt;/script&gt;
1239 &lt;!-- Ouput widget --&gt;
1240 &lt;script src=&quot;js/parsers/parser-input-select.js&quot;&gt;&lt;/script&gt;
1241 &lt;script src=&quot;js/widgets/widget-ouput.js&quot;&gt;&lt;/script&gt;</pre>
1242 </div>
1243
1244 <h1>CSS</h1>
1245 <div id="css">
1246 <pre class="prettyprint lang-css"></pre>
1247 </div>
1248
1249 <h1>Script</h1>
1250 <div id="javascript">
1251 <pre class="prettyprint lang-js"></pre>
1252 </div>
1253
1254 <h1>HTML</h1>
1255 <div id="html">
1256 <pre class="prettyprint lang-html"></pre>
1257 </div>
1258
1259 </div>
1260
1261 </body>
1262 </html>