Debian Codegraph @

docs/example-widget-column-selector.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery tablesorter 2.0 - Column Selector 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 rel="stylesheet" href="css/jq.css">
16 <link href="css/prettify.css" rel="stylesheet">
17 <script src="js/prettify.js"></script>
18 <script src="js/docs.js"></script>
19
20 <!-- Tablesorter: required -->
21 <link rel="stylesheet" href="../css/theme.blue.css">
22 <script src="../js/jquery.tablesorter.js"></script>
23 <script src="../js/jquery.tablesorter.widgets.js"></script>
24
25 <script src="../js/widgets/widget-columnSelector.js"></script>
26 <style>
27 /* override document styling */
28 .popover.right { text-align: left; }
29 .ui-widget-content a { color: #428bca; }
30 </style>
31
32 <style id="css">/*** custom css only popup ***/
33 .columnSelectorWrapper {
34 position: relative;
35 margin: 10px 0;
36 display: inline-block;
37 }
38 .columnSelector, .hidden {
39 display: none;
40 }
41 .columnSelectorButton {
42 background: #99bfe6;
43 border: #888 1px solid;
44 color: #111;
45 border-radius: 5px;
46 padding: 5px;
47 }
48 #colSelect1:checked + label {
49 background: #5797d7;
50 border-color: #555;
51 }
52 #colSelect1:checked ~ #columnSelector {
53 display: block;
54 }
55 .columnSelector {
56 width: 120px;
57 position: absolute;
58 top: 30px;
59 padding: 10px;
60 background: #fff;
61 border: #99bfe6 1px solid;
62 border-radius: 5px;
63 }
64 .columnSelector label {
65 display: block;
66 }
67 .columnSelector label:nth-child(1) {
68 border-bottom: #99bfe6 solid 1px;
69 margin-bottom: 5px;
70 }
71 .columnSelector input {
72 margin-right: 5px;
73 }
74 .columnSelector .disabled {
75 color: #ddd;
76 }
77
78 /*** Bootstrap popover ***/
79 #popover-target label {
80 margin: 0 5px;
81 display: block;
82 }
83 #popover-target input {
84 margin-right: 5px;
85 }
86 #popover-target .disabled {
87 color: #ddd;
88 }
89 </style>
90
91 <script id="js">$(function() {
92
93 /*** custom css only button popup ***/
94 $(".custom-popup").tablesorter({
95 theme: 'blue',
96 widgets: ['zebra', 'columnSelector', 'stickyHeaders'],
97 widgetOptions : {
98 // target the column selector markup
99 columnSelector_container : $('#columnSelector'),
100 // column status, true = display, false = hide
101 // disable = do not display on list
102 columnSelector_columns : {
103 0: 'disable' /* set to disabled; not allowed to unselect it */
104 },
105 // remember selected columns (requires $.tablesorter.storage)
106 columnSelector_saveColumns: true,
107
108 // container layout
109 columnSelector_layout : '<label><input type="checkbox">{name}</label>',
110 // layout customizer callback called for each column
111 // function($cell, name, column) { return name || $cell.html(); }
112 columnSelector_layoutCustomizer : null,
113 // data attribute containing column name to use in the selector container
114 columnSelector_name : 'data-selector-name',
115
116 /* Responsive Media Query settings */
117 // enable/disable mediaquery breakpoints
118 columnSelector_mediaquery: true,
119 // toggle checkbox name
120 columnSelector_mediaqueryName: 'Auto: ',
121 // breakpoints checkbox initial setting
122 columnSelector_mediaqueryState: true,
123 // hide columnSelector false columns while in auto mode
124 columnSelector_mediaqueryHidden: true,
125
126 // set the maximum and/or minimum number of visible columns; use null to disable
127 columnSelector_maxVisible: null,
128 columnSelector_minVisible: null,
129 // responsive table hides columns with priority 1-6 at these breakpoints
130 // see http://view.jquerymobile.com/1.3.2/dist/demos/widgets/table-column-toggle/#Applyingapresetbreakpoint
131 // *** set to false to disable ***
132 columnSelector_breakpoints : [ '20em', '30em', '40em', '50em', '60em', '70em' ],
133 // data attribute containing column priority
134 // duplicates how jQuery mobile uses priorities:
135 // http://view.jquerymobile.com/1.3.2/dist/demos/widgets/table-column-toggle/
136 columnSelector_priority : 'data-priority',
137
138 // class name added to checked checkboxes - this fixes an issue with Chrome not updating FontAwesome
139 // applied icons; use this class name (input.checked) instead of input:checked
140 columnSelector_cssChecked : 'checked',
141
142 // class name added to rows that have a span (e.g. grouping widget & other rows inside the tbody)
143 columnSelector_classHasSpan : 'hasSpan',
144
145 // event triggered when columnSelector completes
146 columnSelector_updated : 'columnUpdate'
147 }
148 });
149
150 /*** Bootstrap popover demo ***/
151
152 // initialize column selector using default settings
153 // note: no container is defined!
154 $(".bootstrap-popup").tablesorter({
155 theme: 'blue',
156 widgets: ['zebra', 'columnSelector', 'stickyHeaders']
157 });
158
159 // call this function to copy the column selection code into the popover
160 $.tablesorter.columnSelector.attachTo( $('.bootstrap-popup'), '#popover-target');
161
162 $('#popover')
163 .popover({
164 placement: 'right',
165 html: true, // required if content has HTML
166 content: $('#popover-target')
167 });
168
169 });
170 </script>
171 </head>
172 <body>
173
174 <div id="banner">
175 <h1>table<em>sorter</em></h1>
176 <h2>Column Selector Widget</h2>
177 <h3>Flexible client-side table sorting</h3>
178 <a href="index.html">Back to documentation</a>
179 </div>
180
181 <div id="main">
182
183 <p></p>
184 <br>
185
186 <div id="root" class="accordion">
187
188 <h3><a href="#">Notes</a></h3>
189 <div>
190 <ul>
191 <li>In <span class="version">v2.29.0</span>, added a <code>columnSelector_classHasSpan</code> setting.</li>
192 <li>In <span class="version">v2.27.0</span>,
193 <ul>
194 <li>Added two new options: <code>columnSelector_maxVisible</code> and <code>columnSelector_minVisible</code>.</li>
195 <li>These settings set a maximum and/or minimum number of visible columns. <strong>Please see the option description for each setting for important details!</strong></li>
196 <li>The <code>refreshColumnSelector</code> method is not constrained by these limitations. Only user interaction is restricted.</li>
197 </ul>
198 </li>
199 <li>In <span class="version">v2.25.9</span>,
200 <ul>
201 <li>Added a <code>columnSelector_maxPriorities</code> setting.</li>
202 <li>Using the "refreshColumnSelector" method now properly saves the settings if the <code>columnSelector_saveColumns</code> is <code>true</code>.</li>
203 <li>The widget still uses the <code>filter_filteredRow</code> setting, but now falls back to using "filtered" when it is undefined.</li>
204 </ul>
205 </li>
206 <li>In <span class="version">v2.24.0</span>,
207 <ul>
208 <li>This widget now supports extra rows and <code>colspan</code> cells in the header &amp; footer (not the body). The first demo has been updated to show this enhancement.</li>
209 <li>Added <code>columnSelector_mediaqueryHidden</code> option.</li>
210 </ul>
211 </li>
212 <li>In <span class="version">v2.23.2</span>, added <code>columnSelector_updated</code> option.</li>
213 <li>In <span class="version updated">v2.23.0</span>, updated methods to allow refreshing the content of the container &amp; enchanced ability to set both auto and columns modes.</li>
214 <li>In <span class="version updated">v2.19.0</span>, the <code>refreshColumnSelector</code> method has been updated to allow passing a parameter. Pass an array of zero-based column indexes of columns to show, or any non-array to enable auto mode (if available).</li>
215 <li>In <span class="version">v2.18.4</span>, added <code>columnSelector_cssChecked</code> option which contains the class name added to checked inputs. This helps fix an issue in Chrome that rears it's ugly head when trying to use <code>input:checked</code> to change a Font Awesome icon. See <a href="http://jsfiddle.net/2tu38gez">this demo</a> by TheSin which uses this option to change the checkbox style.</li>
216 <li>
217 In <span class="version">v2.17.0</span>, a method to refresh the column selector was added.<br>
218 <br>
219 </li>
220 <li>This widget will <strong>only work</strong> in tablesorter version 2.8+ and jQuery version 1.7+.</li>
221 <li>This widget may not work properly if the table body contains rows with <code>rowspan</code> or <code>colspan</code> settings.</li>
222 <li>The responsive part of this widget:
223 <ul>
224 <li>Uses similar parameters as those used by jQuery mobile to set <a href="http://view.jquerymobile.com/1.4.0/demos/table-column-toggle/">column priority</a>.</li>
225 <li>The column priorities range from 1 to 6, with 1 having the highest priority. As the browser window shrinks, lower priority (higher numbers) columns will be hidden first until all numbered priority columns are hidden.</li>
226 <li>Any named data-priority, other than the numbers 1 - 6, (e.g. "critical" or "persistent") will be treated as a column which <em>will not be included</em> in the column selector.</li>
227 <li>Note that this widget uses media queries, which <a href="http://caniuse.com/#search=media">will not work in IE8 and older browsers</a>.</li>
228 </ul>
229 </li>
230 <li>The selector code uses css selectors, for optimal speed, to hide/show columns. These selectors <a href="http://caniuse.com/#search=nth-child">will not work in IE8 and older browsers</a>.</li>
231 <li>The column button &amp; popup is completely customizable, and in this demo it includes css that may not work properly in older versions of IE.</li>
232 </ul>
233 </div>
234
235 <h3><a href="#">Options</a></h3>
236 <div>
237 <h4>Column selector widget default options (added inside of tablesorter <code>widgetOptions</code>)</h4>
238 <div>
239 <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.
240 </div>
241 <table class="options tablesorter-blue" data-sortlist="[[0,0]]">
242 <thead>
243 <tr><th width="5%">Option</th><th class="sorter-false">Description</th></tr>
244 </thead>
245 <tbody>
246
247 <tr id="column-selector-container">
248 <td><a href="#" class="permalink">columnSelector_container</a></td>
249 <td>
250 Target an element within the current page where the column selector will be inserted.
251 <div class="collapsible">
252 <br>
253 <ul>
254 <li>This setting is optional. If not set, you can use the following function to attach it to another element - see the Bootstrap example below
255 <pre class="prettyprint lang-js">$.tablesorter.columnSelector.attachTo( $('table'), '.selector-target' );</pre>
256 </li>
257 <li>This can be either a jQuery selector string ( e.g. <code>'#columnSelector'</code> )</li>
258 <li>or, a jQuery object ( e.g. <code>$('#columnSelector')</code> ).</li>
259 </ul>
260 Default value: <code>null</code>
261 </div>
262 </td>
263 </tr>
264
265 <tr id="column-selector-columns">
266 <td><a href="#" class="permalink">columnSelector_columns</a></td>
267 <td>
268 Assigns a column status for each selector
269 <div class="collapsible">
270 <br>
271 <ul>
272 <li>To disable, or remove a column from the column selector, include the key word <code>&quot;disable&quot;</code> - this is one of many ways to remove a column from the column selector popup</li>
273 <li>Set a column status to <code>true</code> to initially display a column. This is the default for undefined columns.</li>
274 <li>Set a column status to <code>false</code> to initially hide a column.</li>
275 <li>Examples:
276 <pre class="prettyprint lang-js">widgetOptions : {
277 columnSelector_columns : {
278 0 : &quot;disable&quot;, /* disable; i.e. remove column from selector */
279 1 : false, /* start with column hidden */
280 2 : true, /* start with column visible; default for undefined columns */
281 }
282 }</pre></li>
283 <li>
284 <span class="label label-warning">*NOTE*</span> Prior to v2.15.6, using these extra methods and setting a column to "false" would remove it from the selector. Now, it is more consistent with this columns option - set the appropriate method to "disable" to remove a column, "false" to initially hide a column and "true" to keep the column in an initially visible state.<br>
285 <br>
286 In <span class="version">v2.15.6</span>, the following methods in order of priority are now available (set to true, false or disable):
287 <ul>
288 <li>jQuery data <code>data-columnSelector="true"</code> or <code>data-columnSelector="false"</code>.</li>
289 <li>metadata <code>class=&quot;{ columnSelector : true }&quot;</code> or <code>class=&quot;{ columnSelector : false }&quot;</code>.</li>
290 <li>headers option <code>headers : { 0 : { columnSelector: true } }</code> or <code>headers : { 0 : { columnSelector: false } }</code>.</li>
291 <li>header class name <code>class=&quot;columnSelector-true&quot;</code> or <code>class=&quot;columnSelector-false&quot;</code>.</li>
292 </ul>
293 </li>
294 </ul>
295 <p><span class="label label-warning">*NOTE*</span> Setting a column to initially be visible (<code>true</code>) or invisible (<code>false</code>) will be overridden by the users saved selections if the <code>columnSelector_saveColumns</code> option is <code>true</code>.</p>
296 <p><span class="label label-info">NOTE</span> If only using this widget to hide columns, set the <code>columnSelector_mediaquery</code> option to <code>false</code>. Otherwise, you'll also need to set a <code>data-priority</code> in each column header.</p>
297 Default value: <code>{}</code>; empty object
298 </div>
299 </td>
300 </tr>
301
302 <tr id="column-selector-save-columns">
303 <td><a href="#" class="permalink">columnSelector_saveColumns</a></td>
304 <td>Save the current manually set column status and the table's responsive ("auto") state (<span class="version updated">v2.15.7</span>).
305 <div class="collapsible">
306 <br>
307 This option requires the storage utility contained within the tablesorter widgets file (<code>jquery.tablesorter.widgets.js</code>).<br>
308 <br>
309 Default value: <code>true</code>
310 </div>
311 </td>
312 </tr>
313
314 <tr id="column-selector-layout">
315 <td><a href="#" class="permalink">columnSelector_layout</a></td>
316 <td>
317 This option defines the markup used for each column selector within the popup.
318 <div class="collapsible">
319 <br>
320 The only available parameter is the <code>{name}</code> string which will be replaced with the appropriate column name/title.<br>
321 <br>
322 An <code>&lt;input type=&quot;checkbox&quot;&gt;</code> is required within this setting! The label element is optional.<br>
323 <br>
324 Default value: <code>'&lt;label&gt;&lt;input type=&quot;checkbox&quot;&gt;{name}&lt;/label&gt;'</code>
325 </div>
326 </td>
327 </tr>
328
329 <tr id="column-selector-layout-customizer">
330 <td><a href="#" class="permalink">columnSelector_layoutCustomizer</a></td>
331 <td>
332 This option is set as a callback function that is called during the processing of the layout for each column.
333 <div class="collapsible">
334 <br>
335 <p>This callback contains three parameters:</p>
336 <ul>
337 <li><code>$cell</code> - jQuery object pointing to the header cell inner wrapper. If the <a href="index.html#headertemplate"><code>headerTemplate</code></a> option is set as an empty string, then the inner wrapper is not included, and the <code>$cell</code> would then point to the table cell (<code>th</code> or <code>td</code> depending on the markup).</li>
338 <li><code>name</code> - This parameter contains the header cell title string. This value is obtained from the header cell <code>data-selector-name</code> attribute, if defined, or the header cell text.</li>
339 <li><code>index</code> - The current column index as a number value.</li>
340 </ul>
341 <pre class="prettyprint lang-js">$(function() {
342 $("#task").tablesorter({
343 widgets: ["columnSelector"],
344 widgetOptions: {
345 columnSelector_container: $('#columnSelector'),
346 columnSelector_layoutCustomizer: function($cell, name, index) {
347 // return the HTML for the first column only
348 return index === 0 ? $cell.html() : name;
349 }
350 }
351 });
352 });</pre>
353 Default value: <code>null</code>
354 </div>
355 </td>
356 </tr>
357
358 <tr id="column-selector-name">
359 <td><a href="#" class="permalink">columnSelector_name</a></td>
360 <td>
361 The data-attribute within the table header cell which contains an alternate column selector name.
362 <div class="collapsible">
363 <br>
364 <ul>
365 <li>If the header cell does not have this attribute defined, the column selector name will be taken from the header cell internal text.</li>
366 <li>If defined, the text contained within this attribute will replace the <code>{name}</code> string within the layout option above.</li>
367 </ul>
368 Default value: <code>'data-selector-name'</code>
369 </div>
370 </td>
371 </tr>
372
373 <tr id="column-selector-mediaquery">
374 <td><a href="#" class="permalink">columnSelector_mediaquery</a></td>
375 <td>Set this option to add (<code>true</code>) or not add (<code>false</code>) the media query functionality of this widget.
376 <div class="collapsible">
377 <br>
378 When <code>true</code>, an "auto" checkbox is included along with the column checkboxes:
379 <ul>
380 <li>When the "auto" checkbox is checked, all column checkboxes are disabled and media queries are active (columns will hide or show based on the browser width).</li>
381 <li>If "auto" is unchecked, media queries are disabled and column (non-critial/not disabled) visibility is based on the column checkbox setting.</li>
382 </ul>
383 <span class="label label-info">Note</span> When set to <code>true</code>, this option <em>requires</em> the <code>data-priority</code> attributes (name set by the <code>columnSelector_priority</code> option) be set in each header column
384 <pre class="prettyprint lang-html">&lt;th data-priority="critical"&gt;Rank&lt;/th&gt;</pre>
385 See <code>columnSelector_priority</code> for more details.
386 <p>Default value: <code>true</code></p>
387 </div>
388 </td>
389 </tr>
390
391 <tr id="column-selector-mediaquery-name">
392 <td><a href="#" class="permalink">columnSelector_mediaqueryName</a></td>
393 <td>When the media query checkbox is added (it also uses the <code>columnSelector_layout</code> markup), this is the name that is added.
394 <div class="collapsible">
395 <br>
396 Set as "Auto" to signify to the user that columns disappearing and/or reappearing is automatically done.<br>
397 <br>
398 Default value: <code>'Auto: '</code>
399 </div>
400 </td>
401 </tr>
402
403 <tr id="column-selector-mediaquery-state">
404 <td><a href="#" class="permalink">columnSelector_mediaqueryState</a></td>
405 <td>Set this option to <code>false</code> to start with the media query disabled (manual column selection mode).
406 <div class="collapsible">
407 <br>
408 Default value: <code>true</code>
409 </div>
410 </td>
411 </tr>
412
413 <tr id="column-selector-mediaquery-hidden">
414 <td><a href="#" class="permalink">columnSelector_mediaqueryHidden</a></td>
415 <td>When this option is set to <code>true</code> columns with a "columnSelector-false" class will be hidden while media queries ("auto" mode) are active (<span class="version">v2.24.0</span>).
416 <div class="collapsible">
417 <br>
418 <ul>
419 <li>With this option set to <code>true</code>, the hidden state of a column can be set using any of the following methods, added to the header cell, in order of priority:
420 <ul>
421 <li>jQuery data <code>data-columnSelector="false"</code>.</li>
422 <li>metadata <code>class=&quot;{ columnSelector : false }&quot;</code> (requires the metadata plugin).</li>
423 <li>headers option <code>headers : { 0 : { columnSelector: 'false' } }</code>.</li>
424 <li>header class name <code>class=&quot;columnSelector-false&quot;</code>.</li>
425 </ul>
426 </li>
427 </ul>
428 <p>See <a href="https://github.com/Mottie/tablesorter/issues/964">issue #964</a> for more details.</p>
429 Default value: <code>false</code>
430 </div>
431 </td>
432 </tr>
433
434 <tr id="column-selector-max-visible">
435 <td><a href="#" class="permalink">columnSelector_maxVisible</a></td>
436 <td>Set this option to a number to set a maximum number of visible columns (<span class="version">v2.27.0</span>).
437 <div class="collapsible">
438 <br>
439 <span class="label label-info">Note</span>
440 <ul>
441 <li>The initial state is not limited by this option. If you have a maximum number set and no columns hidden by class (<code>columnSelector-false</code> or by <code>columnSelector_columns</code> option, then all columns will be visible!</li>
442 <li>The setting <em>does not</em> take into account the disabled columns (columns not listed in the column selector).</li>
443 <li>So, in the first example below, the "Name" and "Major" columns are disabled (not included in the popup).</li>
444 <li>If this option was set to <code>2</code>, only two additional columns, not counting the "Name" and "Major" columns can be made visible.</li>
445 </ul>
446 <p>Set this value to <code>null</code> to disable it.</p>
447 Default value: <code>null</code>
448 </div>
449 </td>
450 </tr>
451 <tr id="column-selector-min-visible">
452 <td><a href="#" class="permalink">columnSelector_minVisible</a></td>
453 <td>Set this option to a number to set a minimum number of visible columns (<span class="version">v2.27.0</span>).
454 <div class="collapsible">
455 <br>
456 <span class="label label-info">Note</span>
457 <ul>
458 <li>The initial state is not limited by this option. If you have all columns hidden initially, then all columns will be hidden!</li>
459 <li>The setting <em>does not</em> take into account the disabled columns (columns not listed in the column selector).</li>
460 <li>So, in the first example below, the "Name" and "Major" columns are disabled (not included in the popup).</li>
461 <li>If this option was set to <code>1</code>, then one of the columns, not including the "Name" & "Major" columns, must always be visible.</li>
462 </ul>
463 <p>Set this value to <code>null</code> to disable it.</p>
464 Default value: <code>null</code>
465 </div>
466 </td>
467 </tr>
468
469 <tr id="column-selector-breakpoints">
470 <td><a href="#" class="permalink">columnSelector_breakpoints</a></td>
471 <td>This option defines the media query breakpoints with which to use when a column with the associated priority is hidden or revealed.
472 <div class="collapsible">
473 <br>
474 <ul>
475 <li>For example,
476 <ul>
477 <li>The last entry &quot;70em&quot; (1,120px) is assigned to data-priority 6.</li>
478 <li>When the browser width is below this dimension, all columns with a data-priority of six will be hidden.</li>
479 <li>Then when a browser width less than &quot;60em&quot; (960px) is reached, all columns of data-priority 5 and above will be hidden.</li>
480 <li>At &quot;50em&quot; (800px), all columns of data-priority 4 and above are hidden, etc.</li>
481 </ul>
482 <br>
483 </li>
484 <li>Adjust these values as desired, but a <em>maximum</em> number data-priorities is set by the <code>columnSelector_maxPriorities</code> value (<span class="version updated">v2.25.9</span>).</li>
485 </ul>
486 Default value: <code>[ &quot;20em&quot;, &quot;30em&quot;, &quot;40em&quot;, &quot;50em&quot;, &quot;60em&quot;, &quot;70em&quot; ]</code>
487 </div>
488 </td>
489 </tr>
490 <tr id="column-selector-maxpriority">
491 <td><a href="#" class="permalink">columnSelector_maxPriorities</a></td>
492 <td>This option sets the maximum number of priorities (<span class="version">v2.25.9</span>).
493 <div class="collapsible">
494 <br>
495 <ul>
496 <li>If for some reason you need to change the number of priorities (especially increase the number), then change this setting to reflect the maximum number of available priorities.</li>
497 <li>Then make sure to modify the <code>columnSelector_breakpoints</code> to match this new value.</li>
498 </ul>
499 Default value: <code>6</code>
500 </div>
501 </td>
502 </tr>
503 <tr id="column-selector-priority">
504 <td><a href="#" class="permalink">columnSelector_priority</a></td>
505 <td>
506 This is the assigned data-attribute which contains the defined data priority for a table column
507 <div class="collapsible">
508 <br>
509 <ul>
510 <li>Values of 1 through 6 set the breakpoints of that particular column.</li>
511 <li>A value of 1 has the highest priority, meaning it is the last column(s) to be hidden when the browser width goes below &quot;20em&quot; (320px).</li>
512 <li>A value of 7 has the lowest priority, meaning it is the first column(s) to be hidden when the browser width goes below &quot;70em&quot; (1,120px).</li>
513 <li>Any named priority value, (e.g. "critical" or "persistent") will flag the widget to remove that column from the selector list.</li>
514 <li>Undefined priorities will default to a priority value of 1.</li>
515 </ul>
516 Default value: <code>'data-priority'</code>
517 </div>
518 </td>
519 </tr>
520
521 <tr id="column-selector-css-checked">
522 <td><a href="#" class="permalink">columnSelector_cssChecked</a></td>
523 <td>
524 This class name is added to the input checkbox when it is checked
525 <div class="collapsible">
526 <br>
527 This was added because we found an issue in the latest version of Chrome where the css selector <code>input:checked</code> was not correctly modifying the displayed Font Awesome replacement icon when the checkbox was toggled.<br>
528 <br>
529 Use <code>input.checked</code> (or whatever value setting this class name option contains to get around this issue). See <a href="http://jsfiddle.net/2tu38gez">this demo</a> by TheSin which uses this option to change the checkbox style.<br>
530 <br>
531 Default value: <code>'checked'</code>
532 </div>
533 </td>
534 </tr>
535
536 <tr id="column-selector-class-has-span">
537 <td><a href="#" class="permalink">columnSelector_classHasSpan</a></td>
538 <td>
539 Class name added to rows that have a span (e.g. grouping widget & other rows inside the tbody) (<span class="version">v2.29.0</span>)
540 <div class="collapsible">
541 <p>This was added to allow customizing the css name in case of conflicts.</p>
542 <p>The grouping widget accesses this value to ensure that group rows are not hidden when the first column is toggled.</p>
543 Default value: <code>'hasSpan'</code>
544 </div>
545 </td>
546 </tr>
547
548 <tr id="column-selector-updated">
549 <td><a href="#" class="permalink">columnSelector_updated</a></td>
550 <td>
551 This event is triggered after the columnSelector has completed updating (<span class="version">v2.23.2</span>)
552 <div class="collapsible">
553 <br>
554 <p>Bind to this event if you to need to perform an action after the columnSelector has finished hiding or showing columns.</p>
555 Use it as follows<pre class="prettyprint lang-js">$('table').on('columnUpdate', function() {
556 // set ascending sort on first column
557 $(this).trigger('sorton', [ [[0,0]] ]);
558 });</pre>
559 Default value: <code>'columnUpdate'</code>
560 </div>
561 </td>
562 </tr>
563
564 </tbody>
565 </table>
566
567 </div>
568
569 <h3><a href="#">Methods</a></h3>
570 <div>
571 Refresh the breakpoints and selected columns using this method (<span class="version">v2.17.0</span>):
572 <p></p>
573 <pre class="prettyprint lang-js">$('table').trigger('refreshColumnSelector');</pre>
574 <p>In <span class="version updated">v2.23.0</span>, this method was expanded to allow the refreshing of the selector content &amp; set auto and column modes.</p>
575 <ul>
576 <li>Here are a few examples:
577 <table class="tablesorter-blue">
578 <thead>
579 <th>Method</th>
580 <th>Description</th>
581 </thead>
582 <tbody>
583 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector');</code></td><td>Refresh current settings; mainly used to update the css used to hide/show columns</td></tr>
584 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', [ [2,3,4] ]);</code></td><td>Set visible columns; turn <em>off</em> "auto" mode (original method).</td></tr>
585 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', [ 'columns', [5,6] ]);</code></td><td>Set visible columns; turn <em>off</em> "auto" mode (alternative method).</td></tr>
586 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', true);</code></td><td>Turn <em>on</em> "auto" mode (original method).</td></tr>
587 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', [ 'auto', true ]);</code></td><td>Turn <em>on</em> "auto" mode (alternate method).</td></tr>
588 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', [ 'auto', false ]);</code></td><td>Turn <em>off</em> "auto" mode (alternate method).</td></tr>
589 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', [ 'auto', [2,3,4] ]);</code></td><td>Turn <em>on</em> "auto" mode &amp; set visible columns when "auto" is off.</td></tr>
590 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', 'selectors');</code></td><td>Refresh selector popup contents & maintain "auto" mode; this allows updating column priorities, column names & widget options.</td></tr>
591 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', [ 'selectors', [5,6] ]);</code></td><td>Refresh selector popup contents; Set visible columns &amp; turn <em>off</em> "auto" mode.</td></tr>
592 <tr><td><code class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', [ 'selectors', true ]);</code></td><td>Refresh selector popup contents; Turn <em>on</em> "auto" mode</td></tr>
593 </tbody>
594 </table>
595 The function used for this method was also split out from the event handler, so if you want you can access it directly as follows:
596 <pre class="prettyprint lang-js">var config = $('table')[0].config;
597 // example: refreshColumns( config, 'selectors', [5,6] );
598 $.tablesorter.columnSelector.refreshColumns( config, optionName, optionState );</pre>
599 </li>
600 </ul>
601
602 In <span class="version">v2.19.0</span>, this method will now accept a parameter.
603 <p></p>
604 <ul>
605 <li>
606 The parameter can be either an array of zero-based column indexes to toggle columns on and off:
607 <pre class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', [ [2,3,4] ]);</pre>
608 <span class="label label-info">Note</span>
609 <ul>
610 <li>Passing an array will turn "auto" mode off.</li>
611 <li>Make sure to wrap the array inside another array.</li>
612 <li>Columns marked as "critical" or "disable" will never get toggled off using this method.</li>
613 </ul>
614 <p></p>
615 </li>
616 <li>
617 Or, set the parameter to any non-array value to turn the "auto" mode on - this only works if the <code>columnSelector_mediaquery</code> is set to <code>true</code>:
618 <pre class="prettyprint lang-js">$('table').trigger('refreshColumnSelector', true);</pre>
619 </li>
620 </ul>
621 </div>
622
623 <h3><a href="#">Removing a column from the selector</a></h3>
624 <div>
625 This is probably overkill, but there are numerous ways to remove a column from the selection popup (<span class="version updated">v2.15.6</span>):
626 <ul>
627 <li>Setting the <code>data-priority</code> to any non-numerical name (e.g. "critical" or "persistent").</li>
628 <li>Setting the column selector widget columns option <code>columnSelector_columns : { 0 : 'disable' }</code>.</li>
629 <li>The following methods, added to the header cell, in order of priority:
630 <ul>
631 <li>jQuery data <code>data-columnSelector="disable"</code>.</li>
632 <li>metadata <code>class=&quot;{ columnSelector : disable }&quot;</code> (requires the metadata plugin).</li>
633 <li>headers option <code>headers : { 0 : { columnSelector: 'disable' } }</code>.</li>
634 <li>header class name <code>class=&quot;columnSelector-disable&quot;</code>.</li>
635 </ul>
636 </li>
637 </ul>
638 * <span class="label label-warning">*NOTE*</span> Prior to v2.15.6, setting these methods to "false" would remove it from the selector. Now, they must be set to "disable" to remove the column from the selector, this was done to make it more consistent with the <code>columnSelector_columns</code> setting.
639 </div>
640 </div>
641
642 <p></p>
643
644 <h1>Demo</h1>
645
646 <h3>CSS only popup</h3>
647 <!-- This selector markup is completely customizable -->
648 <div class="columnSelectorWrapper">
649 <input id="colSelect1" type="checkbox" class="hidden">
650 <label class="columnSelectorButton" for="colSelect1">Column</label>
651 <div id="columnSelector" class="columnSelector">
652 <!-- this div is where the column selector is added -->
653 </div>
654 </div> (When "Auto" is set, the table becomes responsive; resize the browser window to see it work)
655
656 <table class="tablesorter custom-popup">
657 <thead>
658 <tr class="tablesorter-ignoreRow">
659 <th colspan="3">Student</th>
660 <th colspan="4">Courses</th>
661 </tr>
662 <tr>
663 <th data-priority="critical">Name</th>
664 <!-- Remove column from selection popup by including -->
665 <!-- data-priority="Anything other than 1-6" OR data-column-selector="disable" OR class="columnSelector-disable" -->
666 <th class="columnSelector-disable">Major</th>
667 <!-- columnSelector-false will initially hide the column; see columnSelector_mediaqueryHidden option -->
668 <th class="columnSelector-false" data-priority="6" data-selector-name="Gender">Sex</th>
669 <th data-priority="4">English</th>
670 <th data-priority="5">Japanese</th>
671 <th data-priority="3">Calculus</th>
672 <th data-priority="2">Geometry</th>
673 </tr>
674 </thead>
675 <tfoot>
676 <tr><th>Name</th><th>Major</th><th>Sex</th><th>English</th><th>Japanese</th><th>Calculus</th><th>Geometry</th></tr>
677 <tr>
678 <th colspan="3">Student</th>
679 <th colspan="4">Courses</th>
680 </tr>
681 </tfoot>
682 <tbody>
683 <tr><td>Student03</td><td>Languages</td><td>female</td><td>85</td><td>95</td><td>80</td><td>85</td></tr>
684 <tr><td>Student04</td><td>Languages</td><td>male</td><td>60</td><td>55</td><td>100</td><td>100</td></tr>
685 <tr><td>Student05</td><td>Languages</td><td>female</td><td>68</td><td>80</td><td>95</td><td>80</td></tr>
686 <tr><td>Student12</td><td>Mathematics</td><td>female</td><td>100</td><td>75</td><td>70</td><td>85</td></tr>
687 <tr><td>Student13</td><td>Languages</td><td>female</td><td>100</td><td>80</td><td>100</td><td>90</td></tr>
688 <tr><td>Student14</td><td>Languages</td><td>female</td><td>50</td><td>45</td><td>55</td><td>90</td></tr>
689 <tr><td>Student15</td><td>Languages</td><td>male</td><td>95</td><td>35</td><td>100</td><td>90</td></tr>
690 <tr><td>Student16</td><td>Languages</td><td>female</td><td>100</td><td>50</td><td>30</td><td>70</td></tr>
691 <tr><td>Student17</td><td>Languages</td><td>female</td><td>80</td><td>100</td><td>55</td><td>65</td></tr>
692 <tr><td>Student18</td><td>Mathematics</td><td>male</td><td>30</td><td>49</td><td>55</td><td>75</td></tr>
693 <tr><td>Student19</td><td>Languages</td><td>male</td><td>68</td><td>90</td><td>88</td><td>70</td></tr>
694 <tr><td>Student20</td><td>Mathematics</td><td>male</td><td>40</td><td>45</td><td>40</td><td>80</td></tr>
695 <tr><td>Student01</td><td>Languages</td><td>male</td><td>80</td><td>70</td><td>75</td><td>80</td></tr>
696 <tr><td>Student02</td><td>Mathematics</td><td>male</td><td>90</td><td>88</td><td>100</td><td>90</td></tr>
697 <tr><td>Student06</td><td>Mathematics</td><td>male</td><td>100</td><td>99</td><td>100</td><td>90</td></tr>
698 <tr><td>Student07</td><td>Mathematics</td><td>male</td><td>85</td><td>68</td><td>90</td><td>90</td></tr>
699 <tr><td>Student08</td><td>Languages</td><td>male</td><td>100</td><td>90</td><td>90</td><td>85</td></tr>
700 <tr><td>Student09</td><td>Mathematics</td><td>male</td><td>80</td><td>50</td><td>65</td><td>75</td></tr>
701 <tr><td>Student10</td><td>Languages</td><td>male</td><td>85</td><td>100</td><td>100</td><td>90</td></tr>
702 <tr><td>Student11</td><td>Languages</td><td>male</td><td>86</td><td>85</td><td>100</td><td>100</td></tr>
703 </tbody>
704 </table>
705
706 <h3>Bootstrap Popover</h3>
707 <!-- Bootstrap popover button -->
708 <button id="popover" type="button" class="btn btn-default">
709 Select Column
710 </button>
711
712 <div class="hidden">
713 <div id="popover-target"></div>
714 </div>
715
716 <table class="tablesorter bootstrap-popup">
717 <thead>
718 <tr>
719 <th data-priority="critical">Rank</th>
720 <th data-priority="3">First Name</th>
721 <th data-priority="critical">Last Name</th>
722 <th data-priority="4">Age</th>
723 <th data-priority="4">Total</th>
724 <th data-priority="5">Discount</th>
725 <th data-priority="6">Date</th>
726 </tr>
727 </thead>
728 <tbody>
729 <tr><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>
730 <tr><td>11</td><td>Aaron</td><td>Hibert</td><td>12</td><td>$2.99</td><td>5%</td><td>Aug 21, 2009 12:21 PM</td></tr>
731 <tr><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>
732 <tr><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>
733 <tr><td>21</td><td>John</td><td>Hood</td><td>33</td><td>$19.99</td><td>25%</td><td>Dec 10, 2002 5:14 AM</td></tr>
734 <tr><td>013</td><td>Clark</td><td>Kent Sr.</td><td>18</td><td>$15.89</td><td>44%</td><td>Jan 12, 2003 11:14 AM</td></tr>
735 <tr><td>005</td><td>Bruce</td><td>Almighty Esq</td><td>45</td><td>$153.19</td><td>44%</td><td>Jan 18, 2021 9:12 AM</td></tr>
736 <tr><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>
737 <tr><td>16</td><td>Jim</td><td>Franco</td><td>24</td><td>$14.19</td><td>14%</td><td>Jan 14, 2004 11:23 AM</td></tr>
738 <tr><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>
739 <tr><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>
740 <tr><td>55</td><td>Dennis</td><td>Bronson</td><td>65</td><td>$123.00</td><td>32%</td><td>Jan 20, 2001 1:12 PM</td></tr>
741 <tr><td>9</td><td>Martha</td><td>delFuego</td><td>25</td><td>$22.09</td><td>17%</td><td>Jun 11, 2011 10:55 AM</td></tr>
742 </tbody>
743 </table>
744
745 <h1>Css</h1>
746 <div id="css">
747 <pre class="prettyprint lang-css"></pre>
748 </div>
749
750 <h1>HTML</h1>
751 <div>
752 <pre class="prettyprint lang-html">&lt;h3&gt;CSS only popup&lt;/h3&gt;
753 &lt;!-- This selector markup is completely customizable --&gt;
754 &lt;div class=&quot;columnSelectorWrapper&quot;&gt;
755 &lt;input id=&quot;colSelect1&quot; type=&quot;checkbox&quot; class=&quot;hidden&quot;&gt;
756 &lt;label class=&quot;columnSelectorButton&quot; for=&quot;colSelect1&quot;&gt;Column&lt;/label&gt;
757 &lt;div id=&quot;columnSelector&quot; class=&quot;columnSelector&quot;&gt;
758 &lt;!-- this div is where the column selector is added --&gt;
759 &lt;/div&gt;
760 &lt;/div&gt;
761
762 &lt;table class=&quot;tablesorter custom-popup&quot;&gt;
763 &lt;thead&gt;
764 &lt;tr class="tablesorter-ignoreRow"&gt; &lt;!-- Ignore all cell content; disable sorting & form interaction --&gt;
765 &lt;th data-priority=&quot;critical&quot;&gt;Name&lt;/th&gt;
766 &lt;!-- Remove column from selection popup by including --&gt;
767 &lt;!-- data-priority=&quot;Anything other than 1-6&quot; OR data-column-selector=&quot;disable&quot; OR class=&quot;columnSelector-disable&quot; --&gt;
768 &lt;th class=&quot;columnSelector-disable&quot;&gt;Major&lt;/th&gt;
769 &lt;!-- columnSelector-false will initially hide the column --&gt;
770 &lt;th class=&quot;columnSelector-false&quot; data-priority=&quot;6&quot; data-selector-name=&quot;Gender&quot;&gt;Sex&lt;/th&gt;
771 &lt;th data-priority=&quot;4&quot;&gt;English&lt;/th&gt;
772 &lt;th data-priority=&quot;5&quot;&gt;Japanese&lt;/th&gt;
773 &lt;th data-priority=&quot;3&quot;&gt;Calculus&lt;/th&gt;
774 &lt;th data-priority=&quot;2&quot;&gt;Geometry&lt;/th&gt;
775 &lt;/tr&gt;
776 &lt;/thead&gt;
777 &lt;tfoot&gt;
778 &lt;tr&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Major&lt;/th&gt;&lt;th&gt;Sex&lt;/th&gt;&lt;th&gt;English&lt;/th&gt;&lt;th&gt;Japanese&lt;/th&gt;&lt;th&gt;Calculus&lt;/th&gt;&lt;th&gt;Geometry&lt;/th&gt;&lt;/tr&gt;
779 &lt;/tfoot&gt;
780 &lt;tbody&gt;
781 &lt;!-- ... --&gt;
782 &lt;/tbody&gt;
783 &lt;/table&gt;
784
785 &lt;h3&gt;Bootstrap Popover&lt;/h3&gt;
786 &lt;!-- Bootstrap popover button --&gt;
787 &lt;button id=&quot;popover&quot; type=&quot;button&quot; class=&quot;btn btn-default&quot;&gt;
788 Select Column
789 &lt;/button&gt;
790
791 &lt;div class=&quot;hidden&quot;&gt;
792 &lt;div id=&quot;popover-target&quot;&gt;&lt;/div&gt;
793 &lt;/div&gt;
794
795 &lt;table class=&quot;tablesorter bootstrap-popup&quot;&gt;
796 &lt;thead&gt;
797 &lt;tr&gt;
798 &lt;th data-priority=&quot;critical&quot;&gt;Rank&lt;/th&gt;
799 &lt;th data-priority=&quot;3&quot;&gt;First Name&lt;/th&gt;
800 &lt;th data-priority=&quot;critical&quot;&gt;Last Name&lt;/th&gt;
801 &lt;th data-priority=&quot;4&quot;&gt;Age&lt;/th&gt;
802 &lt;th data-priority=&quot;4&quot;&gt;Total&lt;/th&gt;
803 &lt;th data-priority=&quot;5&quot;&gt;Discount&lt;/th&gt;
804 &lt;th data-priority=&quot;6&quot;&gt;Date&lt;/th&gt;
805 &lt;/tr&gt;
806 &lt;/thead&gt;
807 &lt;tbody&gt;
808 &lt;!-- ... --&gt;
809 &lt;/tbody&gt;
810 &lt;/table&gt;</pre>
811 </div>
812
813 <h1>Javascript</h1>
814 <div id="javascript">
815 <pre class="prettyprint lang-js"></pre>
816 </div>
817
818 </div>
819
820 </body>
821 </html>