From 12bfd30cbdb733036458f96d77abd42bf5871331 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 10 Sep 2014 11:22:38 +0000 Subject: [PATCH] When user changes the width of a relative width column, make sure that column stays at the set size and adjust all other relative columns to fit. Fixes relative width columns changing width again after being resized. --- etemplate/js/et2_dataview.js | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/etemplate/js/et2_dataview.js b/etemplate/js/et2_dataview.js index 365f6b1f30..c92f7c0b19 100644 --- a/etemplate/js/et2_dataview.js +++ b/etemplate/js/et2_dataview.js @@ -395,9 +395,36 @@ var et2_dataview = Class.extend({ // make column resizable var enc_column = self.columnMgr.getColumnById(col.id); et2_dataview_makeResizeable(column, function(_w) { - this.set_width(this.relativeWidth ? (_w / self.columnMgr.totalWidth) : _w + "px"); - self.columnMgr.updated = true; - self.updateColumns(); + + // User wants the column to stay where they put it, even for relative + // width columns, so set it explicitly first and adjust other relative + // columns to match. + if(this.relativeWidth) + { + // Set to selected width + this.set_width(_w + "px"); + self.columnMgr.updated = true; + self.updateColumns(); + + // Set relative widths to match + var relative = self.columnMgr.totalWidth - self.columnMgr.totalFixed + _w; + this.set_width(_w / relative); + for(var i = 0; i < self.columnMgr.columns.length; i++) + { + var col = self.columnMgr.columns[i]; + if(col == this || col.fixedWidth) continue; + col.set_width(self.columns[i].width / relative); + } + // Don't update now, or columns might change a little. + // Save it for next time. + } + else + { + this.set_width(this.relativeWidth ? (_w / self.columnMgr.totalWidth) : _w + "px"); + self.columnMgr.updated = true; + self.updateColumns(); + } + }, enc_column); // Store both nodes in the columnNodes array