|
1 |
| -/* Widget: columnSelector (responsive table widget) - updated 9/28/2016 (v2.27.8) *//* |
| 1 | +/* Widget: columnSelector (responsive table widget) - updated 12/15/2016 (v2.28.2) *//* |
2 | 2 | * Requires tablesorter v2.8+ and jQuery 1.7+
|
3 | 3 | * by Justin Hallett & Rob Garrison
|
4 | 4 | */
|
|
113 | 113 | },
|
114 | 114 |
|
115 | 115 | setupSelector: function(c, wo) {
|
116 |
| - var index, name, $header, priority, col, colId, |
| 116 | + var index, name, $header, priority, col, colId, $el, |
117 | 117 | colSel = c.selector,
|
118 | 118 | $container = colSel.$container,
|
119 | 119 | useStorage = wo.columnSelector_saveColumns && ts.storage,
|
|
149 | 149 | saved[colId] : (typeof wo.columnSelector_columns[colId] !== 'undefined' && wo.columnSelector_columns[colId] !== null) ?
|
150 | 150 | wo.columnSelector_columns[colId] : (state === 'true' || state !== 'false');
|
151 | 151 | colSel.$column[colId] = $(this);
|
152 |
| - |
153 |
| - // set default col title |
154 |
| - name = $header.attr(wo.columnSelector_name) || $header.text(); |
155 | 152 | if ($container.length) {
|
| 153 | + // set default col title |
| 154 | + name = $header.attr(wo.columnSelector_name) || $header.text().trim(); |
| 155 | + if (typeof wo.columnSelector_layoutCustomizer === "function") { |
| 156 | + $el = $header.find('.' + ts.css.headerIn); |
| 157 | + name = wo.columnSelector_layoutCustomizer( $el.length ? $el : $header, name, parseInt(colId, 10) ); |
| 158 | + } |
156 | 159 | colSel.$wrapper[colId] = $(wo.columnSelector_layout.replace(/\{name\}/g, name)).appendTo($container);
|
157 | 160 | colSel.$checkbox[colId] = colSel.$wrapper[colId]
|
158 | 161 | // input may not be wrapped within the layout template
|
|
270 | 273 | var array = [],
|
271 | 274 | temp = ' col:nth-child(' + column + ')';
|
272 | 275 | array.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
|
273 |
| - temp = ' tr:not(.hasSpan) th:nth-child(' + column + ')'; |
| 276 | + temp = ' tr:not(.hasSpan) th[data-column="' + ( column - 1 ) + '"]'; |
274 | 277 | array.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
|
275 | 278 | temp = ' tr:not(.hasSpan) td:nth-child(' + column + ')';
|
276 | 279 | array.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
|
|
497 | 500 |
|
498 | 501 | // container layout
|
499 | 502 | columnSelector_layout : '<label><input type="checkbox">{name}</label>',
|
| 503 | + // layout customizer callback called for each column |
| 504 | + // function($cell, name, column){ return name || $cell.html(); } |
| 505 | + columnSelector_layoutCustomizer : null, |
500 | 506 | // data attribute containing column name to use in the selector container
|
501 | 507 | columnSelector_name : 'data-selector-name',
|
502 | 508 |
|
|
0 commit comments