"Cannot save settings without a grid persist-key");
return;
}
- var conf = grid.columnsProvider.columns.map(
- function(col) {
- var c = {
- name : col.name,
- flex : col.flex,
- };
- // preserve prefs space by only storing values that
- // are non-default
- if (Number(col.sort)) c.sort = Number(col.sort);
- if (Boolean(col.visible)) c.visible = true;
- return c;
- }
- );
+
+ // only store information about visible columns.
+ var conf = grid.columnsProvider.columns.filter(
+ function(col) {return Boolean(col.visible) });
+
+ // now scrunch the data down to just the needed info
+ conf = conf.map(function(col) {
+ var c = {name : col.name}
+ // Apart from the name, only store non-default values.
+ // No need to store col.visible, since that's implicit
+ if (col.flex != 2) c.flex = col.flex;
+ if (Number(col.sort)) c.sort = Number(c.sort);
+ return c;
+ });
egCore.hatch.setItem('eg.grid.' + grid.persistKey, conf)
.then(function() {
return;
}
- grid_col.flex = col.flex;
+ grid_col.flex = col.flex || 2;
grid_col.sort = col.sort || 0;
- grid_col.visible = col.visible || false;
+ // all saved columns are assumed to be true
+ grid_col.visible = true;
new_cols.push(grid_col);
});
- // check for new columns which are not yet expressed
- // within the saved configuration and tack them onto
- // the end of the columns list
+ // columns which are not expressed within the saved
+ // configuration are marked as non-visible and
+ // appended to the end of the new list of columns.
angular.forEach(columns, function(col) {
var found = conf.filter(
function(c) {return (c.name == col.name)})[0];
- if (!found) new_cols.push(col);
+ if (!found) {
+ col.visible = false;
+ new_cols.push(col);
+ }
});
grid.columnsProvider.columns = new_cols;