ColumnSelector: Set state to null for disabled columns

Fixes JSON issues with not storing "undefined" values
This commit is contained in:
Rob Garrison 2016-07-28 15:36:55 -05:00
parent ff754c177e
commit 76f85018d8
No known key found for this signature in database
GPG Key ID: 0A42D160D71978E1
2 changed files with 7 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@ -72,14 +72,14 @@
isArry = $.isArray(optState || optName), isArry = $.isArray(optState || optName),
wo = c.widgetOptions; wo = c.widgetOptions;
// see #798 // see #798
if (typeof optName !== 'undefined' && colSel.$container.length) { if (typeof optName !== 'undefined' && optName !== null && colSel.$container.length) {
// pass "selectors" to update the all of the container contents // pass "selectors" to update the all of the container contents
if ( optName === 'selectors' ) { if ( optName === 'selectors' ) {
colSel.$container.empty(); colSel.$container.empty();
tsColSel.setupSelector(c, wo); tsColSel.setupSelector(c, wo);
tsColSel.setupBreakpoints(c, wo); tsColSel.setupBreakpoints(c, wo);
// if optState is undefined, maintain the current "auto" state // if optState is undefined, maintain the current "auto" state
if ( typeof optState === 'undefined' ) { if ( typeof optState === 'undefined' && optStates !== null ) {
optState = colSel.auto; optState = colSel.auto;
} }
} }
@ -140,12 +140,13 @@
// include getData check (includes 'columnSelector-false' class, data attribute, etc) // include getData check (includes 'columnSelector-false' class, data attribute, etc)
if ( isNaN(priority) && priority.length > 0 || state === 'disable' || if ( isNaN(priority) && priority.length > 0 || state === 'disable' ||
( wo.columnSelector_columns[colId] && wo.columnSelector_columns[colId] === 'disable') ) { ( wo.columnSelector_columns[colId] && wo.columnSelector_columns[colId] === 'disable') ) {
colSel.states[colId] = null;
continue; // goto next continue; // goto next
} }
// set default state; storage takes priority // set default state; storage takes priority
colSel.states[colId] = saved && typeof saved[colId] !== 'undefined' ? colSel.states[colId] = saved && (typeof saved[colId] !== 'undefined' && saved[colId] === null) ?
saved[colId] : typeof wo.columnSelector_columns[colId] !== 'undefined' ? saved[colId] : (typeof wo.columnSelector_columns[colId] !== 'undefined' && wo.columnsSelector_columns[colId] !== null) ?
wo.columnSelector_columns[colId] : (state === 'true' || state !== 'false'); wo.columnSelector_columns[colId] : (state === 'true' || state !== 'false');
colSel.$column[colId] = $(this); colSel.$column[colId] = $(this);
@ -415,7 +416,7 @@
} else { } else {
$cell.addClass( filtered ); $cell.addClass( filtered );
} }
} else if ( typeof colSel.states[ col ] !== 'undefined' ) { } else if ( typeof colSel.states[ col ] !== 'undefined' && colSel.states[ col ] !== null ) {
$cell.toggleClass( filtered, !colSel.states[ col ] ); $cell.toggleClass( filtered, !colSel.states[ col ] );
} }
} }