mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
ColumnSelector: Add childrow colspan support. See #1120
This commit is contained in:
parent
fa45fea896
commit
cf56b8beb9
@ -237,9 +237,12 @@
|
||||
var array = [],
|
||||
temp = ' col:nth-child(' + column + ')';
|
||||
array.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
|
||||
temp = ' tr th:nth-child(' + column + ')';
|
||||
temp = ' tr:not(.hasSpan) th:nth-child(' + column + ')';
|
||||
array.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
|
||||
temp = ' tr td:nth-child(' + column + ')';
|
||||
temp = ' tr:not(.hasSpan) td:nth-child(' + column + ')';
|
||||
array.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
|
||||
// for other cells in colspan columns
|
||||
temp = ' tr td:not(' + prefix + 'HasSpan)[data-column="' + (column - 1) + '"]';
|
||||
array.push(prefix + temp + ',' + prefix + '_extra_table' + temp);
|
||||
return array;
|
||||
},
|
||||
@ -290,7 +293,7 @@
|
||||
if (mediaAll.length) {
|
||||
colSel.$breakpoints
|
||||
.prop('disabled', false)
|
||||
.html( tsColSel.queryAll.replace(/\[columns\]/g, mediaAll.join(',')) + breakpts );
|
||||
.text( tsColSel.queryAll.replace(/\[columns\]/g, mediaAll.join(',')) + breakpts );
|
||||
}
|
||||
},
|
||||
updateCols: function(c, wo) {
|
||||
@ -312,7 +315,7 @@
|
||||
colSel.$breakpoints.prop('disabled', true);
|
||||
}
|
||||
if (colSel.$style) {
|
||||
colSel.$style.prop('disabled', false).html( styles.length ? styles.join(',') + ' { display: none; }' : '' );
|
||||
colSel.$style.prop('disabled', false).text( styles.length ? styles.join(',') + ' { display: none; }' : '' );
|
||||
}
|
||||
if (wo.columnSelector_saveColumns && ts.storage) {
|
||||
ts.storage( c.$table[0], 'tablesorter-columnSelector', colSel.states );
|
||||
@ -339,7 +342,7 @@
|
||||
.addClass( c.namespace.slice( 1 ) + 'columnselectorHasSpan' )
|
||||
.attr( 'data-col-span', span );
|
||||
// add data-column values
|
||||
ts.computeColumnIndex( $cells.eq( index ).parent() );
|
||||
ts.computeColumnIndex( $cells.eq( index ).parent().addClass( 'hasSpan' ) );
|
||||
}
|
||||
}
|
||||
// only add resize end if using media queries
|
||||
@ -359,15 +362,16 @@
|
||||
}
|
||||
},
|
||||
adjustColspans: function(c, wo) {
|
||||
var index, cols, col, span, end,
|
||||
var index, cols, col, span, end, $cell,
|
||||
colSel = c.selector,
|
||||
autoModeOn = colSel.auto,
|
||||
$colspans = $( c.namespace + 'columnselectorHasSpan' ),
|
||||
len = $colspans.length;
|
||||
if ( len ) {
|
||||
for ( index = 0; index < len; index++ ) {
|
||||
col = parseInt( $colspans.eq(index).attr('data-column'), 10 );
|
||||
span = parseInt( $colspans.eq(index).attr('data-col-span'), 10 );
|
||||
$cell = $colspans.eq(index);
|
||||
col = parseInt( $cell.attr('data-column'), 10 ) || $cell[0].cellIndex;
|
||||
span = parseInt( $cell.attr('data-col-span'), 10 );
|
||||
end = col + span;
|
||||
for ( cols = col; cols < end; cols++ ) {
|
||||
if ( !autoModeOn && colSel.states[ cols ] === false ||
|
||||
@ -376,9 +380,9 @@
|
||||
}
|
||||
}
|
||||
if ( span ) {
|
||||
$colspans.eq(index).show()[0].colSpan = span;
|
||||
$cell.removeClass( wo.filter_filteredRow )[0].colSpan = span;
|
||||
} else {
|
||||
$colspans.eq(index).hide();
|
||||
$cell.addClass( wo.filter_filteredRow );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -479,6 +483,7 @@
|
||||
if (csel.$popup) { csel.$popup.empty(); }
|
||||
csel.$style.remove();
|
||||
csel.$breakpoints.remove();
|
||||
$( c.namespace + 'columnselectorHasSpan' ).removeClass( wo.filter_filteredRow );
|
||||
c.$table.off('updateAll' + namespace + ' update' + namespace);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user