Update nm query when column selection changes, re-query only when columns added

This commit is contained in:
Nathan Gray 2011-10-03 17:14:17 +00:00
parent 3c1bebf3f1
commit 4c593038b0

View File

@ -352,33 +352,54 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
*/ */
_updateUserPreferences: function() { _updateUserPreferences: function() {
var colMgr = this.dataviewContainer.getColumnMgr() var colMgr = this.dataviewContainer.getColumnMgr()
if(this.options.settings.columnselection_pref) { if(!this.options.settings.columnselection_pref) {
var visibility = colMgr.getColumnVisibilitySet(); this.options.settings.columnselection_pref = this.options.template;
var colDisplay = []; }
var colSize = {};
// visibility is indexed by internal ID, widget is referenced by position, preference needs name var visibility = colMgr.getColumnVisibilitySet();
for(var i = 0; i < colMgr.columns.length; i++) var colDisplay = [];
{ var colSize = {};
var widget = this.columns[i].widget;
var colName = this._getColumnName(widget); // visibility is indexed by internal ID, widget is referenced by position, preference needs name
if(colName) { for(var i = 0; i < colMgr.columns.length; i++)
if(visibility[colMgr.columns[i].id].visible) colDisplay.push(colName); {
if(colMgr.columns[i].fixedWidth) colSize[colName] = colMgr.columns[i].fixedWidth; var widget = this.columns[i].widget;
} else if (colMgr.columns[i].fixedWidth) { var colName = this._getColumnName(widget);
et2_debug("info", "Could not save column width - no name", colMgr.columns[i].id); if(colName) {
} if(visibility[colMgr.columns[i].id].visible) colDisplay.push(colName);
if(colMgr.columns[i].fixedWidth) colSize[colName] = colMgr.columns[i].fixedWidth;
} else if (colMgr.columns[i].fixedWidth) {
et2_debug("info", "Could not save column width - no name", colMgr.columns[i].id);
} }
}
var list = et2_csvSplit(this.options.settings.columnselection_pref, 2, ".");
var app = list[0]; var list = et2_csvSplit(this.options.settings.columnselection_pref, 2, ".");
var app = list[0];
// Save visible columns // Save visible columns
// 'nextmatch-' prefix is there in preference name, but not in setting, so add it in // 'nextmatch-' prefix is there in preference name, but not in setting, so add it in
egw.set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref, colDisplay.join(",")); egw.set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref, colDisplay.join(","));
// Save adjusted column sizes // Save adjusted column sizes
egw.set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref+"-size", colSize); egw.set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref+"-size", colSize);
// Update query value, so data source can use visible columns to exclude expensive sub-queries
var oldCols = this.activeFilters.selectcols ? this.activeFilters.selectcols : [];
this.activeFilters.selectcols = colDisplay;
// We don't need to re-query if they've removed a column
var changed = [];
ColLoop:
for(var i = 0; i < colDisplay.length; i++)
{
for(var j = 0; j < oldCols.length; j++) {
if(colDisplay[i] == oldCols[j]) continue ColLoop;
}
changed.push(colDisplay[i]);
}
if(changed.length)
{
this.applyFilters();
} }
}, },