+ +
+
+
+
+
+
+Notes
+
+
+
+ -
+
- This widget will only work in tablesorter version 2.8+ and jQuery version 1.7+. +
- This widget may not work properly if the table header includes rows with row or column spans. +
- The responsive part of this widget
+
-
+
- Uses similar parameters as those used by jQuery mobile to set column priority. +
- Any named data-priority, other than the numbers 1 - 6, (e.g. "critical" or "persistent") will be treated as a column which will not be included in the column selector. +
- Note that this widget uses media queries, which will not work in IE8 and older browsers. +
+ - The selector code uses css selectors, for optimal speed, to hide/show columns. These selectors will not work in IE8 and older browsers. +
- The column button & popup is completely customizable, and in this demo it includes css that may not work properly in older versions of IE. +
Options
+
+ Column selector widget default options (added inside of tablesorter
+
+
+ Column selector widget default options (added inside of tablesorter widgetOptions
)
+ -
+
columnSelector_container
(null
) - Target an element within the current page where the column selector will be inserted. +-
+
- This can be either a jQuery selector string ( e.g.
'#columnSelector'
)
+ - or, a jQuery object ( e.g.
$('#columnSelector')
).
+
+ - This can be either a jQuery selector string ( e.g.
columnSelector_columns
({}
; empty object) - Assigns a column status for each selector: +-
+
- To disable, or remove a column from the column selector, include the key word
"disable"
- this is one of many ways to remove a column from the column selector popup
+ - Set a column status to
true
to initially display a column. This is the default for undefined columns.
+ - Set a column status to
false
to initially hide a column.
+ - Examples:
+
widgetOptions : { + columnSelector_columns : { + 0 : "disable", /* disable; i.e. remove column from selector */ + 1 : false, /* start with column hidden */ + 2 : true, /* start with column visible; default for undefined columns */ + } +}
+ columnSelector_saveColumns
(true
) - Save the current manually set column status (not the column's responsive state). This option requires the storage utility contained within the tablesorter widgets file (jquery.tablesorter.widgets.js
).
+ columnSelector_layout
('<label><input type="checkbox">{name}</label>'
) - This option defines the markup used for each column selector within the popup. The only required parameter is the{name}
string which will be replaced with the appropriate column name/title.
+
+ columnSelector_name
("data-selector-name"
) - The data-attribute within the table header cell which contains an alternate column selector name. +-
+
- If the header cell does not have this attribute defined, the column selector name will be taken from the header cell internal text. +
- If defined, the text contained within this attribute will replace the
{name}
string within the layout option above.
+
+
+ columnSelector_mediaquery
(true
) - Set this option to add (true
) or not add (false
) the media query functionality of this widget.
+ columnSelector_mediaqueryName
("Auto: "
) - When the media query checkbox is added (it also uses thecolumnSelector_layout
markup), this is the name that is added. Set as "Auto" to signify to the user that columns disappearing and/or reappearing is automatically done.
+ columnSelector_mediaqueryState
(true
) - Set this option tofalse
to start with the media query disabled (manual column selection mode).
+ columnSelector_breakpoints
([ "20em", "30em", "40em", "50em", "60em", "70em" ]
) +-
+
- This option defines the media query breakpoints with which to use when a column with the associated priority is hidden or revealed. +
- For example, the last entry "70em" (1,120px) is assigned to data-priority 6. When the browser width is below this dimension, all columns with a data-priority of six will be hidden. Then when a browser width less than "60em" (960px) is reached, all columns of data-priority 5 and above will be hidden. At "50em" (800px), all columns of data-priority 4 and above are hidden, etc. +
- Adjust these values as desired, but a maximum of six data-priorities is set. +
+ columnSelector_priority
("data-priority"
) - This is the assigned data-attribute which contains the defined data priority for a table column. +-
+
- Values of 1 through 6 set the breakpoints of that particular column. +
- A value of 1 has the highest priority, meaning it is the last column(s) to be hidden when the browser width goes below "20em" (320px). +
- A value of 7 has the lowest priority, meaning it is the first column(s) to be hidden when the browser width goes below "70em" (1,120px). +
- Any named priority value, (e.g. "critical" or "persistent") will flag the widget to remove that column from the selector list. +
- Undefined priorities will default to a priority value of 1. +
+
- To disable, or remove a column from the column selector, include the key word
Removing a column from the selector
+
+ This is probably overkill, but there are numerous ways to remove a column from the selection popup:
+
+ -
+
- Setting the
data-priority
to any non-numerical name (e.g. "critical" or "persistent").
+ - Setting the column selector widget columns option
columnSelector_columns : { 0 : 'disable' }
.
+ - The following methods in order of priority:
+
-
+
- jQuery data
data-columnSelector="false"
.
+ - metadata
class="{ columnSelector : false }"
.
+ - headers option
headers : { 0 : { columnSelector: false } }
.
+ - header class name
class="columnSelector-false"
.
+
+ - jQuery data
Demo
+ + +
+
+
+
+
+
+
+
+Name | + + +Major | +Sex | +English | +Japanese | +Calculus | +Geometry | +
---|---|---|---|---|---|---|
Name | Major | Sex | English | Japanese | Calculus | Geometry |
Student12 | Mathematics | female | 100 | 75 | 70 | 85 |
Student13 | Languages | female | 100 | 80 | 100 | 90 |
Student14 | Languages | female | 50 | 45 | 55 | 90 |
Student15 | Languages | male | 95 | 35 | 100 | 90 |
Student16 | Languages | female | 100 | 50 | 30 | 70 |
Student17 | Languages | female | 80 | 100 | 55 | 65 |
Student18 | Mathematics | male | 30 | 49 | 55 | 75 |
Student19 | Languages | male | 68 | 90 | 88 | 70 |
Student20 | Mathematics | male | 40 | 45 | 40 | 80 |
Student21 | Languages | male | 50 | 45 | 100 | 100 |
Student22 | Mathematics | male | 100 | 99 | 100 | 90 |
Student23 | Languages | female | 85 | 80 | 80 | 80 |
Student01 | Languages | male | 80 | 70 | 75 | 80 |
Student02 | Mathematics | male | 90 | 88 | 100 | 90 |
Student03 | Languages | female | 85 | 95 | 80 | 85 |
Student04 | Languages | male | 60 | 55 | 100 | 100 |
Student05 | Languages | female | 68 | 80 | 95 | 80 |
Student06 | Mathematics | male | 100 | 99 | 100 | 90 |
Student07 | Mathematics | male | 85 | 68 | 90 | 90 |
Student08 | Languages | male | 100 | 90 | 90 | 85 |
Student09 | Mathematics | male | 80 | 50 | 65 | 75 |
Student10 | Languages | male | 85 | 100 | 100 | 90 |
Student11 | Languages | male | 86 | 85 | 100 | 100 |
Student24 | Languages | female | 100 | 91 | 13 | 82 |
Css
+
+
+
+
+ HTML
+
+
+
+ <!-- This selector markup is completely customizable --> +<div class="columnSelectorWrapper"> + <input id="colSelect1" type="checkbox" class="hidden"> + <label class="columnSelectorButton" for="colSelect1">Column</label> + <div id="columnSelector" class="columnSelector"> + <!-- this div is where the column selector is added --> + </div> +</div> + +<table class="tablesorter"> + <thead> + <tr> + <th data-priority="critical">Name</th> + <!-- Remove column from selection popup by including --> + <!-- data-priority="Anything other than 1-6" OR data-column-selector="false" OR class="columnSelector-false" --> + <th class="columnSelector-false">Major</th> + <th data-priority="6">Sex</th> + <th data-priority="4">English</th> + <th data-priority="5">Japanese</th> + <th data-priority="3">Calculus</th> + <th data-priority="2">Geometry</th> + </tr> + </thead> + <tfoot> + <tr><th>Name</th><th>Major</th><th>Sex</th><th>English</th><th>Japanese</th><th>Calculus</th><th>Geometry</th></tr> + </tfoot> + <tbody> + <!-- ... --> + </tbody> +</table>+
Javascript
+
+
+
+
+