Start of column resizing. Works OK in chrome, FF needs some work.

This commit is contained in:
Nathan Gray 2011-09-29 22:57:42 +00:00
parent c956d6571b
commit 43e75da558
3 changed files with 58 additions and 6 deletions

View File

@ -351,6 +351,9 @@ var et2_dataview_gridContainer = Class.extend({
* Builds the containers for the header row
*/
_buildHeader: function() {
var self = this;
var handler = function(event) {
}
for (var i = 0; i < this.columns.length; i++)
{
var col = this.columns[i];
@ -359,11 +362,33 @@ var et2_dataview_gridContainer = Class.extend({
var cont = $j(document.createElement("div"))
.addClass("innerContainer")
.addClass(col.divClass);
var column = $j(document.createElement("th"))
.addClass(col.tdClass)
.append(cont)
.appendTo(this.headTr);
// Every column but last can be resized
if(i < this.columns.length-1) {
var enc_column = self.columnMgr.getColumnById(col.id);
column.resizable({
handles:"e",
helper: "nextmatch_resize_helper",
stop: (function(columnIdx, enc_column) { return function(event, ui) {
var original = self.columnMgr.columnWidths[columnIdx];
var newWidth = original + (ui.size.width - ui.originalSize.width);
// Using full height helper stretches the header - reset it
// TODO: Get rid of magic -5
if(jQuery(this).height() > ui.originalSize.height) jQuery(this).height(ui.originalSize.height-5);
enc_column.set_width(newWidth+ "px");
self.columnMgr.updated = true;
self.updateColumns();
};})(i, enc_column)
});
}
// Store both nodes in the columnNodes array
this.columnNodes.push({
"column": column,

View File

@ -287,7 +287,12 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
for(var i = 0; i < children.length; i++) {
if(children[i].id) child_names.push(children[i].id);
}
return name + (name != "" && child_names.length > 0 ? "_" : "") + child_names.join("_");
var colName = name + (name != "" && child_names.length > 0 ? "_" : "") + child_names.join("_");
if(colName == "") {
et2_debug("info", "Unable to generate nm column name for ", _widget);
}
return colName;
},
@ -300,6 +305,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
var columnPreference = negated ? this.options.settings.default_cols.substring(1) : this.options.settings.default_cols;
if(this.options.settings.columnselection_pref) {
var list = et2_csvSplit(this.options.settings.columnselection_pref, 2, ".");
var app = list[0];
// 'nextmatch-' prefix is there in preference name, but not in setting, so add it in
var pref = egw.preference("nextmatch-"+this.options.settings.columnselection_pref, list[0]);
if(pref)
@ -310,6 +316,14 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
}
var columnDisplay = et2_csvSplit(columnPreference,null,",");
// Adjusted column sizes
var size = {};
if(this.options.settings.columnselection_pref && app)
{
size = egw.preference("nextmatch-"+this.options.settings.columnselection_pref+"-size", app);
}
if(!size) size = {};
// Add in display preferences
if(columnDisplay && columnDisplay.length > 0)
{
@ -318,7 +332,8 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
{
var colName = this._getColumnName(_row[i].widget);
if(!colName) continue;
_colData[i].preferenceName = colName;
if(size[colName]) _colData[i].width = size[colName];
for(var j = 0; j < columnDisplay.length; j++) {
if(columnDisplay[j] == colName)
{
@ -329,7 +344,6 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
_colData[i].disabled = !negated;
}
}
// TODO: Adjusted column sizes
},
/**
@ -341,14 +355,19 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
if(this.options.settings.columnselection_pref) {
var visibility = colMgr.getColumnVisibilitySet();
var colDisplay = [];
var colSize = [];
var colSize = {};
// visibility is indexed by internal ID, widget is referenced by position, preference needs name
for(var i = 0; i < colMgr.columns.length; i++)
{
var widget = this.columns[i].widget;
var colName = this._getColumnName(widget);
if(visibility[colMgr.columns[i].id].visible) colDisplay.push(colName);
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, ".");
@ -358,7 +377,8 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
// '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(","));
// TODO: Save adjusted column sizes
// Save adjusted column sizes
egw.set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref+"-size", colSize);
}
},

View File

@ -544,6 +544,13 @@ label input, label span, label div, label select, label textarea {
background-image: url(gfx/down.png);
}
.nextmatch_resize_helper {
border-right: 1px dotted gray;
min-height: 100%;
background-color: gray;
opacity: 0.5;
}
.et2_clickable {
cursor: pointer;
}