You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2007/06/05 02:06:24 UTC
svn commit: r544343 - in /incubator/xap/trunk/codebase/src/xap:
bridges/dojo/TableBridge.js widgets/dojo/TreeTable.js
Author: mturyn
Date: Mon Jun 4 19:06:23 2007
New Revision: 544343
URL: http://svn.apache.org/viewvc?view=rev&rev=544343
Log:
Reverting versions
TableBride.js > March 19, 2007
TreeTable.js > April 4, 2007
Modified:
incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js
incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js?view=diff&rev=544343&r1=544342&r2=544343
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js Mon Jun 4 19:06:23 2007
@@ -27,8 +27,7 @@
Xap.require("xap.bridges.dojo.DojoWidgetBridge");
Xap.require("xap.widgets.dojo.TreeTable");
-Xap.require("dojo.html");
-Xap.require("xap.util.CssUtils");
+
/**
@@ -39,10 +38,13 @@
xap.bridges.dojo.TableBridge= function() {
xap.bridges.dojo.DojoWidgetBridge.call(this);
-};
+}
-Xap.setupClassAsSubclassOf("xap.bridges.dojo.TableBridge", "xap.bridges.dojo.DojoWidgetBridge");
+Xap.setupClassAsSubclassOf(
+ "xap.bridges.dojo.TableBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+);
@@ -51,41 +53,18 @@
dojo.event.connect(this.getPeer(), "onActivateRow",this,"onActivateRow");
dojo.event.connect(this.getPeer(), "onSelectRow",this,"onSelectRow");
dojo.event.connect(this.getPeer(), "onDeselectRow",this,"onDeselectRow");
- dojo.event.connect(this.getPeer(), "onExpandRow",this,"onExpandRow");
-
-};
-
+ dojo.event.connect(this.getPeer(), "onExpandRow",this,"onExpandRow");
+}
xap.bridges.dojo.TableBridge.prototype.getPeerString = function(){
return "TreeTable" ;
-};
-
-
-xap.bridges.dojo.TableBridge.prototype.obtainPeer = function(){
- xap.bridges.dojo.TableBridge.superclass.obtainPeer.call(this) ;
- var peer = this.getPeer() ;
- if( !peer._tableLayoutModel){
- peer._tableLayoutModel = {} ;
- }
- var h = this.getElement().getAttribute("height") ;
- if( h ){
- peer._tableLayoutModel.initialHeight = h ;
- }
- var w = this.getElement().getAttribute("width") ;
- if( w ){
- peer._tableLayoutModel.initialWidth = w ;
- }
-};
-
-
-
+}
xap.bridges.dojo.TableBridge.prototype.onActivateRow = function( a ){
var clientEvent = new xap.session.ClientEvent(this.getElement(), this.getSession());
clientEvent.rowId = this.getSelectedRowIds();
this.fireEvent("onSelect", null, null, clientEvent);
-};
-
+}
xap.bridges.dojo.TableBridge.prototype.onExpandRow = function( row, expanded ){
var handler = this.getUiContentHandler().getHandlerForPeer(row);
@@ -93,14 +72,13 @@
var clientEvent = new xap.session.ClientEvent(this.getElement(), this.getSession());
clientEvent.rowId = handler.getElement().getAttribute("id");
this.fireEvent(expanded?"onExpand":"onCollapse", null, null, clientEvent);
-};
+}
xap.bridges.dojo.TableBridge.prototype.onDeselectRow = function( row ){
var handler = this.getUiContentHandler().getHandlerForPeer(row);
handler.writeBackRemoveAttribute("selected");
-};
-
+}
xap.bridges.dojo.TableBridge.prototype.onSelectRow = function( row ){
var handler = this.getUiContentHandler().getHandlerForPeer(row);
@@ -108,8 +86,7 @@
var clientEvent = new xap.session.ClientEvent(this.getElement(), this.getSession());
clientEvent.rowId = this.getSelectedRowIds();
this.fireEvent("onStateChange", null, null, clientEvent);
-};
-
+}
xap.bridges.dojo.TableBridge.prototype.getSelectedRowIds = function(){
var s = "";
@@ -117,15 +94,15 @@
for (var i=0; i<selectedItems.length; i++){
var row = selectedItems[i];
var handler = this.getUiContentHandler().getHandlerForPeer(row);
- if (handler){
- if (s.length !== 0){
- s += (',');
+ if (handler!=null){
+ if (s.length!=0){
+ s+=(',');
}
- s += handler.getElement().getAttribute("id");
+ s+= handler.getElement().getAttribute("id");
}
}
return s;
-};
+}
/**
*
@@ -138,31 +115,16 @@
/**
* Dynamic attributes
*/
-xap.bridges.dojo.TableBridge.prototype.getNewAllowedAttributes = function() {
- return [
- "altColor",
- "altBackgroundColor",
- "highlightColor",
- "highlightBackgroundColor",
- "horizontalLineColor",
- "verticalLineColor",
- "collapsedImage",
- "expandedImage"];
-};
-
-
+xap.bridges.dojo.TableBridge.prototype.getNewAllowedAttributes = function(){
+ return [];
+}
xap.bridges.dojo.TableBridge.prototype.setHeightAttribute = function(value){
this.getPeer().setHeight (value);
-};
-
-xap.bridges.dojo.TableBridge.prototype.setWidthAttribute = function(aWidth){
- this.getPeer().setWidth(aWidth) ;
-};
+}
+
xap.bridges.dojo.TableBridge.prototype.addChild = function(childHandler, index){
-// TODO: implement "addSelfToTable" methods on child peers
-// so that we can reduce this to four polymorphic lines:
var childPeer = childHandler.getPeer();
if (childPeer instanceof xap.widgets.dojo.TableColumn){
//TODO interpret index correctly
@@ -171,8 +133,7 @@
else if (childPeer instanceof xap.widgets.dojo.TableRow){
this.getPeer().insertRow(childPeer,-1);
}
-};
-
+}
// handler for removing children
xap.bridges.dojo.TableBridge.prototype.removeChild = function( childHandler ){
@@ -184,228 +145,4 @@
else if (childPeer instanceof xap.widgets.dojo.TableRow){
this.getPeer().removeRow(childPeer);
}
-};
-
-
-//=============================== ATTRIBUTE HELPERS
-
-
-/**
- * Returns global CSS rule "." and CSS class name
- *
- * @return CSS rule object
- */
-xap.bridges.dojo.TableBridge.prototype.getGlobalRule = function(cssClassName) {
- var globalRule = xap.util.CssUtils.getCSSRule('.' + cssClassName);
- return globalRule;
-};
-
-
-/**
- * Returns local CSS rule by combining element id and CSS class name
- *
- * @return CSS rule object
- */
-xap.bridges.dojo.TableBridge.prototype.getLocalRule = function(cssClassName, bCreate) {
- var id = this.getRootDomNode().getAttribute('id');
- var selector = 'div#' + id + ' .' + cssClassName;
- var localRule = xap.util.CssUtils.getCSSRule(selector);
- if(!localRule && bCreate ) {
- // create local rule
- var globalRule = this.getGlobalRule(cssClassName);
- if( globalRule ){
- dojo.html.insertCssRule(selector, globalRule.style.cssText);
- localRule = xap.util.CssUtils.getCSSRule(selector);
- } else {
- xap.log.Logger.getRootLogger().error('Missing CSS rule ' + cssClassName);
- }
- }
- return localRule;
-};
-
-
-//=============================== ATTRIBUTE SETTERS
-
-
-/** XML attribute set method for "altColor" */
-xap.bridges.dojo.TableBridge.prototype.setAltColorAttribute = function(value) {
- var cssClassName = this.getPeer()._alternateRowClass;
- // "true" == "create one if there isn't one extant"
- var localRule = this.getLocalRule(cssClassName, true);
- if( localRule && localRule.style ){
- localRule.style.color = value ;
- } else {
- xap.log.Logger.getRootLogger().error('Unable to create local rule ' + cssClassName);
- }
- // create local selected row class to prevent override
- this.getLocalRule(this.getPeer()._selectedRowClass, true);
-};
-
-/** XML attribute remove method for "altColor" */
-xap.bridges.dojo.TableBridge.prototype.attributeRemovers.altColor = function() {
- var cssClassName = this.getPeer()._alternateRowClass;
- var localRule = this.getLocalRule(cssClassName);
- if(localRule) { localRule.style.color = ''; }
-};
-
-//==
-
-/** XML attribute set method for "altBackgroundColor" */
-xap.bridges.dojo.TableBridge.prototype.setAltBackgroundColorAttribute = function(value) {
- var cssClassName = this.getPeer()._alternateRowClass;
- var localRule = this.getLocalRule(cssClassName);
- // "true" == "create one if there isn't one extant"
- var localRule = this.getLocalRule(cssClassName, true);
- if( localRule && localRule.style ){
- localRule.style.backgroundColor = value;
- } else {
- xap.log.Logger.getRootLogger().error('Unable to create local rule ' + cssClassName);
- }
- // create local selected row class to prevent override
- this.getLocalRule(this.getPeer()._selectedRowClass, true);
-};
-
-/** XML attribute remove method for "altBackgroundColor" */
-xap.bridges.dojo.TableBridge.prototype.attributeRemovers.altBackgroundColor = function() {
- var cssClassName = this.getPeer()._alternateRowClass;
- var localRule = this.getLocalRule(cssClassName);
- if(localRule) { localRule.style.backgroundColor = ''; }
-};
-
-
-//==
-
-/** XML attribute set method for "highlightColor" */
-xap.bridges.dojo.TableBridge.prototype.setHighlightColorAttribute = function(value) {
- var cssClassName = this.getPeer()._selectedRowClass;
- // "true" == "create one if there isn't one extant"
- var localRule = this.getLocalRule(cssClassName, true);
- if( localRule && localRule.style ){
- localRule.style.color = value ;
- } else {
- xap.log.Logger.getRootLogger().error('Unable to create local rule ' + cssClassName);
- }
-};
-
-/** XML attribute remove method for "highlightColor" */
-xap.bridges.dojo.TableBridge.prototype.attributeRemovers.highlightColor = function() {
- var cssClassName = this.getPeer()._selectedRowClass;
- var localRule = this.getLocalRule(cssClassName);
- if(localRule) { localRule.style.color = ''; }
-};
-
-
-//==
-
-
-/** XML attribute set method for "highlightBackgroundColor" */
-xap.bridges.dojo.TableBridge.prototype.setHighlightBackgroundColorAttribute = function(value) {
- var cssClassName = this.getPeer()._selectedRowClass;
- // "true" == "create one if there isn't one extant"
- var localRule = this.getLocalRule(cssClassName, true);
- if( localRule && localRule.style ){
- localRule.style.backgroundColor = value;
- } else {
- xap.log.Logger.getRootLogger().error('Unable to create local rule ' + cssClassName);
- }
-};
-
-/** XML attribute remove method for "highlightBackgroundColor" */
-xap.bridges.dojo.TableBridge.prototype.attributeRemovers.highlightBackgroundColor = function() {
- var cssClassName = this.getPeer()._selectedRowClass;
- var localRule = this.getLocalRule(cssClassName);
- if(localRule) { localRule.style.backgroundColor = ''; }
-};
-
-
-//==
-
-
-/** XML attribute set method for "horizontalLineColor" */
-xap.bridges.dojo.TableBridge.prototype.setHorizontalLineColorAttribute = function(value) {
- var cssClassName = this.getPeer()._tableCellClass;
- // "true" == "create one if there isn't one extant"
- var localRule = this.getLocalRule(cssClassName, true);
- if( localRule && localRule.style ){
- localRule.style.borderBottomColor = value;
- } else {
- xap.log.Logger.getRootLogger().error('Unable to create local rule ' + cssClassName);
- }
-};
-
-/** XML attribute remove method for "horizontalLineColor" */
-xap.bridges.dojo.TableBridge.prototype.attributeRemovers.horizontalLineColor = function() {
- var cssClassName = this.getPeer()._tableCellClass;
- var localRule = this.getLocalRule(cssClassName);
- if(localRule) { localRule.style.borderBottomColor = ''; }
-};
-
-
-//==
-
-
-/** XML attribute set method for "verticalLineColor" */
-xap.bridges.dojo.TableBridge.prototype.setVerticalLineColorAttribute = function(value) {
- var cssClassName = this.getPeer()._tableCellClass;
- // "true" == "create one if there isn't one extant"
- var localRule = this.getLocalRule(cssClassName, true);
- if( localRule && localRule.style ){
- localRule.style.borderRightColor = value;
- } else {
- xap.log.Logger.getRootLogger().error('Unable to create local rule ' + cssClassName);
- }
-};
-
-/** XML attribute remove method for "verticalLineColor" */
-xap.bridges.dojo.TableBridge.prototype.attributeRemovers.verticalLineColor = function() {
- var cssClassName = this.getPeer()._tableCellClass;
- var localRule = this.getLocalRule(cssClassName);
- if(localRule) { localRule.style.borderRightColor = ''; }
-};
-
-
-//==
-
-
-/** XML attribute set method for "collapsedImage" */
-xap.bridges.dojo.TableBridge.prototype.setCollapsedImageAttribute = function(value) {
- var cssClassName = 'ImgNodeCollapsed';
- // "true" == "create one if there isn't one extant"
- var localRule = this.getLocalRule(cssClassName, true);
- if( localRule && localRule.style ){
- localRule.style.backgroundImage = 'url(' + value + ')';
- } else {
- xap.log.Logger.getRootLogger().error('Unable to create local rule ' + cssClassName);
- }
-};
-
-/** XML attribute remove method for "collapsedImage" */
-xap.bridges.dojo.TableBridge.prototype.attributeRemovers.collapsedImage = function() {
- var cssClassName = 'ImgNodeCollapsed';
- var localRule = this.getLocalRule(cssClassName);
- if(localRule) { localRule.style.backgroundImage = ''; }
-};
-
-
-//==
-
-
-/** XML attribute set method for "expandedImage" */
-xap.bridges.dojo.TableBridge.prototype.setExpandedImageAttribute = function(value) {
- var cssClassName = 'ImgNodeExpanded';
- // "true" == "create one if there isn't one extant"
- var localRule = this.getLocalRule(cssClassName, true);
- if( localRule && localRule.style ){
- localRule.style.backgroundImage = 'url(' + value + ')';
- } else {
- xap.log.Logger.getRootLogger().error('Unable to create local rule ' + cssClassName);
- }
-};
-
-/** XML attribute remove method for "expandedImage" */
-xap.bridges.dojo.TableBridge.prototype.attributeRemovers.expandedImage = function() {
- var cssClassName = 'ImgNodeExpanded';
- var localRule = this.getLocalRule(cssClassName);
- if(localRule) { localRule.style.backgroundImage = ''; }
-};
-
+}
Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js?view=diff&rev=544343&r1=544342&r2=544343
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js Mon Jun 4 19:06:23 2007
@@ -17,7 +17,7 @@
*
*/
-// Mark!
+
Xap.provide("xap.widgets.dojo.TreeTable");
Xap.provide("xap.widgets.dojo.TableColumn");
@@ -31,9 +31,6 @@
Xap.require("dojo.style");
Xap.require("dojo.event");
Xap.require("xap.util.ArrayHelper");
-Xap.require("xap.widgets.dojo.DivWrapper");
-
-
//IMPORTANT move this to some shared area
dojo.widget.manager.registerWidgetPackage("xap.widgets.dojo");
@@ -56,18 +53,11 @@
dojo.widget.HtmlWidget.call(this);
this._rebuildTableLater();
-
- this._selectedRowClass = "selectedRow";
this._alternateRowClass = "alternateRow";
this._tableCellClass = "tableCell";
-
this._headerVisibility = "visible";
this._initialResizePending = true;
-
- // width of each column sizer, in pixels:
- this._sizerWidth = 1;
-
-};
+}
dojo.inherits(xap.widgets.dojo.TreeTable,dojo.widget.HtmlWidget);
@@ -75,62 +65,16 @@
//TODO calc padding after laying out headers?
//this is a bad strategy in general, the problem is we want the inner table
//to be sized at 100%
- templateString:
-'<div style="padding:0px 0px 0px 0px; overflow:hidden;position:relative;text-align:left">'
- + '<div dojoAttachPoint="splitterContainer"></div>'
- + '<div dojoAttachPoint="headerDiv">'
- + '<table dojoAttachPoint="headerTable" border="1" style="position:relative;table-layout:fixed;">'
- + '<tbody dojoAttachPoint="headerTbody">'
- + '<tr dojoAttachPoint="headerRow"></tr>'
- + '</tbody>'
- + '</table>'
- + '</div>'
- + '<div dojoAttachPoint="scrollDiv" style="overflow:auto;width:100%;height:100%;">'
- + '<table dojoAttachPoint="table" style="height:100%;">'
- + '<thead dojoAttachPoint="spacerRow"></thead>'
- + '<tbody></tbody>'
- + '</table>'
- + '</div>'
-+ '</div>',
-
-
+ templateString: '<div style="padding:0px 0px 0px 0px; overflow:hidden;position:relative;text-align:left">' +
+ '<div dojoAttachPoint="headerDiv"><table dojoAttachPoint="headerTable" style="position:relative;width:100%;table-layout:fixed;">' +
+ '<tbody dojoAttachPoint="headerTbody"><tr dojoAttachPoint="headerRow"></tr></tbody></table></div>'+
+ '<div dojoAttachPoint="scrollDiv" style="overflow:auto;width:100%;height:100%;">' +
+ '<table dojoAttachPoint="table" style="height:100%;"><tbody></tbody></table></div></div>',
templateCssPath: null ,
widgetType: "TreeTable",
isContainer: false,
defaultCellInfo: {_text:""},
- // Delay between setting height or width and
- // resetting scrollDiv overflow back to "auto"
- // (previously set to "hidden" at the start
- // of setHeight() or setWidth()):
- _resetScrollDivDelayMs: (dojo.render.html.moz)?0:0,
- // Delay between resetting scrollDiv overflow
- // back to "auto" and checking to see the results of that:
- _finishScrollDivDelayMs: (dojo.render.html.moz)?0:100,
-
-// Debugging
-// _ctr:-1 ,
-// loggit: function(aString){
-// Xap.logString+="^"+(++this._ctr)
-// +"\t"+aString+"\t";
-// if(this.table){
-// Xap.logString
-// +=this.table.clientWidth +"\t"+this.domNode.clientWidth ;
-// }
-// },
-
- postCreate: function(){ //debug::this.loggit('postCreate') ;
- xap.widgets.dojo.TreeTable.superclass.postCreate.apply(this,arguments) ;
- this._created = true ;
- if( !this._tableLayoutModel ){
- this._tableLayoutModel = {} ;
- }
-// debugging:
-// window.foo = this ;
- },
-
-
-
/**
*
*
@@ -142,19 +86,18 @@
/**
* Rebuild just the rows of the table, typically called after sorting.
*/
- _rebuildRowsLater : function(delay){ //debug::this.loggit('_rebuildRowsLater ') ;
+ _rebuildRowsLater : function(){
//if a full rebuild is pending don't bother
if (!this._rebuildTableTask && !this._rebuildRowsTask){
- var theDelay = delay || 0 ;
- this._rebuildRowsTask = dojo.lang.setTimeout(this, this._rebuildRows, delay);
+ this._rebuildRowsTask = dojo.lang.setTimeout(this, this._rebuildRows, 0);
}
},
/**
* Rebuilds the entire table from scratch, should be a very rare occurence.
*/
- _rebuildTableLater: function(delay){ //debug::this.loggit('_rebuildTableLater') ;
+ _rebuildTableLater: function(){
//cancel any partial rebuild tasks
if (this._rebuildRowsTask){
@@ -167,9 +110,8 @@
}
//if not already scheduled then schedule it
- var theDelay = delay || 0 ;
if (!this._rebuildTableTask){
- this._rebuildTableTask = dojo.lang.setTimeout(this, this._rebuildTable, theDelay);
+ this._rebuildTableTask = dojo.lang.setTimeout(this, this._rebuildTable, 0);
}
},
@@ -177,13 +119,13 @@
* Once the table is built/sized run through
* and make sure headers and column widths agree
*/
- _resizeTableLater: function(){ //debug::this.loggit('_resizeTableLater') ;
+ _resizeTableLater: function(){
if (!this._resizeTableTask){
this._resizeTableTask = dojo.lang.setTimeout(this, this._resizeTable, 0);
}
},
- _getSizeFromString: function(val){ //debug::this.loggit('_getSizeFromString') ;
+ _getSizeFromString: function(val){
var s = new String(val);
var i = s.search ("px");
if ( i > 0 ) return Number(s.substr(0,i));
@@ -195,38 +137,15 @@
* After a table has been built to the screen go through and make sure
* the widths of columns and headers match up.
*/
- _resizeTable: function(){ //debug::this.loggit('_resizeTable') ;
+ _resizeTable: function(){
var tableWidth = 0;
-
+
//don't user tbody.childNodes[0] here because in the case
//where we need to fix up IE we want to fixup and THEN remove
//and re-add rows in the new order.
var firstRow = this._rows.length>0?this._rows[0].domNode:null;
- // Spacing gets screwed-up under IE if the first row isn't complete,
- // so complete it if need be:
- var len = -1 ;
- if( dojo.render.html.ie
- && firstRow
- && this._columns
- && (len=this._columns.length)>1
- ){
- while(firstRow.childNodes.length<len){
- var filler = document.createElement("td");
- filler.style.backgroundColor = "transparent" ;
- firstRow.appendChild(filler) ;
- }
- }
-
-
var tableWidth = 0;
- // No need to test for these each iteration:
- var hasHeaders = this.headerRow && this.headerRow.childNodes ;
- var hasFirstRow = firstRow && firstRow.childNodes ;
- var hasHeaderTable = this.headerTable && this.headerTable.childNodes ;
- var hasBodyTable = this.table && this.table.childNodes ;
-
-
for (var i=0; i<this._columns.length;i++){
var headerWidth = 0;
@@ -235,210 +154,92 @@
//In IE get/set of column width dynamically doesn't seem to work
//too well so use first row instead
-
- var node = null ;
if (dojo.render.html.ie){
- if( hasHeaders && (node = this.headerRow.childNodes[i])){
- headerWidth
- // = node.offsetWidth;
- = node.clientWidth;
- }
- node = null ;
- if ( hasFirstRow && (node = firstRow.childNodes[i]) ){
- columnWidth
- = node.clientWidth ;
+ var headerWidth = this.headerRow.childNodes[i].offsetWidth;
+ if (firstRow && firstRow.childNodes[i]){
+ columnWidth = firstRow.childNodes[i].offsetWidth;
}
}
else{
- if( hasHeaderTable
- && (node = this.headerTable.childNodes[i])
- ){
- headerWidth
- = node.clientWidth ;
- }
- node=null;
- if( hasBodyTable
- && (node = this.table.childNodes[i])){
- columnWidth
- = node.clientWidth ;
- }
+ headerWidth = this.headerTable.childNodes[i].offsetWidth;
+ columnWidth = this.table.childNodes[i].offsetWidth;
}
- /* if the user explicitly set the column width or
- its header's width , we use those (preferring
- as usual the last value parsed, that is,
- the header's):
- */
-
- var setWidth = this._columns[i].getBestWidth() ;
-
- // We want to set the column width to the explicitly-given value
- // if it should be available from the column or its header); if
- // a value is not available so, we'll use the greater of the
- // extant cell or column widths. Note that we need to look
- // up the explicitly-set ones in case the table is hidden when created
- var preferredColumnWidth = setWidth ;
- if( !setWidth ){
- preferredColumnWidth = headerWidth>columnWidth ? headerWidth:columnWidth;
- preferredColumnWidth += "px" ;
- }
- var preferredColumnWidthPx = parseInt(preferredColumnWidth) ;
- this._columns[i].setStatedWidth(preferredColumnWidth) ;
- if(this.columnsSizer
- && this.columnsSizer.children
- && this.columnsSizer.children[i]
- ){
- this.columnsSizer.children[i].sizeShare = preferredColumnWidthPx ;
- }
- tableWidth += preferredColumnWidthPx ;
+ /* if the user explicitly set, we use those */
+ if ( this._columns[i]._headerWidth ) {
+ var val = this._getSizeFromString (this._columns[i]._headerWidth);
+ if ( val ) setWidth = val;
+ }
+
+ // we want the greater of explicity set, calculated column or calculated cell; note that we need to look up
+ // the explicity set ones in case the table is hidden when created
+ var finalWidth = headerWidth>columnWidth ? headerWidth:columnWidth;
+ finalWidth = setWidth>finalWidth?setWidth:finalWidth;
+ this._columns[i]._calculatedWidth = finalWidth + "px";
+ tableWidth += finalWidth;
}
-
+
//if we don't fix the width here then when we want the table
//to scroll horizontally it doesn't work very well, sizes
//too small
- if( tableWidth != 0 ){
- this.table.style.width = tableWidth + "px";
- this.headerTable.style.width = tableWidth + "px";
- this.headerDiv.style.width
- = "100%";
-
- this.headerTable.style.tableLayout = "fixed";
- this.table.style.tableLayout = "fixed";
-
-
- if( !this._tableLayoutModel.resetWidthPx
- && !this._tableLayoutModel.initialWidth
- ){
- this.domNode.style.width = tableWidth +"px" ;
- } else {
- if( this._tableLayoutModel.initialWidth ){
- // We get this one directly from the XAL
- // element, so it could easily be a percentage
- // or in a non-pixel unit:
- this.domNode.style.width = this._tableLayoutModel.initialWidth ;
- } else {
- // ...whereas _we_ set this, and know
- // it to be a number giving the width
- // in pixels:
- this.domNode.style.width = this._tableLayoutModel.resetWidthPx+"px";
- }
- }
-
- this._fixColumnWidths();
- } else {
- // Best for Tree
- // TODO: break out {column/header}less behavious
- // into a separate class?
- this.table.style.width=this.domNode.clientWidth+"px" ;
- }
-
- dojo.lang.setTimeout(this,this._reconcileHeaderAndBodyColumns,0);
+ this.table.style.width = tableWidth + "px";
+ this.headerTable.style.width = tableWidth + "px";
- if( this._resizeTableTask ){
- window.clearTimeout(this._resizeTableTask);
- this._resizeTableTask = null;
- }
+ this.headerTable.style.tableLayout = "fixed";
+ this.table.style.tableLayout = "fixed";
+ this._fixColumnWidths();
+
+ window.clearTimeout(this._resizeTableTask);
+ this._resizeTableTask = null;
},
- _fixColumnWidths : function(){ //debug::this.loggit('_fixColumnWidths ') ;
- if( this._columns.length==0){
- this.table.style.width="100%" ;
- return ;
- }
-
-
-
+ _fixColumnWidths : function(){
var firstRow = this._rows.length>0?this._rows[0].domNode:null;
-
-
for (var i=0; i<this._columns.length;i++){
- // Note: ends with "px":
- var width = this._columns[i].getBestWidth();
- //...so use this:
- var nWidth = parseInt(width) ;
-
- width = (nWidth)+"px" ;
-
- var widthObj = {width: nWidth};
-
-
+ var width = this._columns[i]._calculatedWidth; // Note: ends with "px"
+
if (dojo.render.html.ie){
-
- if( this.headerRow.childNodes[i] ){
- dojo.html.setMarginBox( this.headerRow.childNodes[i],
- widthObj ) ;
- }
-
- widthObj = dojo.html.getMarginBox( this.headerRow.childNodes[i]) ;
- delete widthObj.height ;
- //widthObj.width += 1 ;
+ dojo.html.setMarginBox( this.headerRow.childNodes[i],
+ {width: parseInt(width)} ) ;
+
if (firstRow && firstRow.childNodes[i]){
dojo.html.setMarginBox( firstRow.childNodes[i],
- widthObj) ;
+ {width: parseInt(width)} ) ;
}
}
- else {
- // Cols are direct children of headerTable;
- // they're evidently sufficient under mozilla to
- // set the columns on-screen:
- if(this.headerTable.childNodes[i]){
- dojo.html.setMarginBox(
- this.headerTable.childNodes[i],
- widthObj
- ) ;
- }
- if(this.table.childNodes[i] && this.headerTable.childNodes[i] ){
- widthObj = dojo.html.getMarginBox( this.headerTable.childNodes[i]) ;
- delete widthObj.height ;
- dojo.html.setMarginBox(
- this.table.childNodes[i],
- widthObj
- ) ;
- }
+ else{
+ this.headerTable.childNodes[i].style.width = width;
+ this.table.childNodes[i].style.width = width;
}
- if (this.headerRow.childNodes[i] && this.headerRow.childNodes[i].childNodes[0]){
- this.headerRow.childNodes[i].childNodes[0].style.width = "100%";
- if( this.columnsSizer ){
- this.columnsSizer.children[i].sizeShare
- = nWidth ;
- }
- }
+ if (this.headerRow.childNodes[i].childNodes[0])
+ this.headerRow.childNodes[i].childNodes[0].style.width = "100%";
}
-
},
/**
* Rebuilds just the real table part of table, not
* the headers.
*/
- _rebuildBody: function(){ //debug::this.loggit('_rebuildBody') ;
-
+ _rebuildBody: function(){
this.domNode.removeChild(this.scrollDiv);
this.scrollDiv = document.createElement("div");
this.domNode.appendChild(this.scrollDiv);
- /*
- calculate the scroll pane height as
- the body height less the heights of
- the header and a possible horizontal
- scrollbar:
- */
+ /* calculate the scroll pane as the body less the height of the header */
var contentHt = "100%";
- var ht = this.domNode.clientHeight
- - this.headerDiv.clientHeight
- -this.getHorizontalScrollbarHeightPx() ;
+ var ht = this.domNode.clientHeight - this.headerDiv.clientHeight;
//in IE the calculated height can be negative because
//clientHeight can be zero
if ( ht > 0 ) contentHt = ht + "px";
-
+
dojo.lang.mixin(this.scrollDiv.style,{
position:"relative",
width:"100%",
height: contentHt,
overflow:"auto"});
-
+
dojo.event.connect(this.scrollDiv, "onscroll", this, "onScrollCallback");
this.table = document.createElement("table");
@@ -460,7 +261,7 @@
* Rebuilds only the rows in the table, leaving the columns in place
* with the same sizes. Useful for sorting.
*/
- _rebuildRows: function(){ //debug::this.loggit('_rebuildRows') ;
+ _rebuildRows: function(){
if (this.tbody){
this.table.removeChild(this.tbody);
}
@@ -472,60 +273,37 @@
for (var i =0; i<this._rows.length; i++){
this._rebuildRow(this._rows[i], 0);
}
- if( this._rebuildRowsTask ){
- window.clearTimeout(this._rebuildRowsTask);
- this._rebuildRowsTask = null;
- }
+ window.clearTimeout(this._rebuildRowsTask);
+ this._rebuildRowsTask = null;
// resize columns in the case of new rows added
- // ---absolutely avoid this if we've just sorted.
-
- if(this._justSorted ){
- delete this._justSorted ;
- } else {
- this._resizeTable();
- }
+ this._resizeTable ();
this._recolorAlternateRows();
- this._redoSplitPanelStyling(1000) ;
},
- getVerticalScrollbarWidthPx: function(){ //debug::this.loggit('getVerticalScrollbarWidthPx') ;
- return this.scrollDiv.offsetWidth - this.scrollDiv.clientWidth ;
- },
-
- getHorizontalScrollbarHeightPx: function(){ //debug::this.loggit('getHorizontalScrollbarHeightPx') ;
- return this.scrollDiv.offsetHeight - this.scrollDiv.clientHeight ;
- },
-
/**
* Rebuilds just the head (column headers)
- * of the table. Skip sizers or outer dom node
- * if we've just shifted a column sizer:
+ * of the table.
*/
- _rebuildHead: function(){ //debug::this.loggit('_rebuildHead') ;
+ _rebuildHead: function(){
this._headerVisibility = this.headerDiv.style.visibility;
+ this.domNode.removeChild(this.headerDiv);
- this.domNode.removeChild(this.headerDiv);
- this.headerDiv = document.createElement("div");
+ this.headerDiv = document.createElement("div");
this.domNode.appendChild(this.headerDiv);
-
- //this.headerDiv.style.width="1000px";
- this.headerDiv.style.width
- = "100%" ;
- this.headerDiv.style.width = this.headerDiv.scrollWidth +"px" ;
-
+ //this.headerDiv.style.width="1000px";
+ this.headerDiv.style.width="100%";
this.headerDiv.style.position="relative";
this.headerDiv.style.textAlign="left";
dojo.html.addClass(this.headerDiv,'xapHeaderBackground');
this.headerTable = document.createElement("table");
this.headerDiv.appendChild(this.headerTable);
-
-
+
this.headerTable.cellPadding = "0px";
- this.headerTable.cellSpacing = "0px";
+ this.headerTable.cellSpacing= "0px";
//populate cols under both tables
for (var i = 0; i<this._columns.length; i++){
@@ -537,55 +315,18 @@
this.headerBody = document.createElement("tbody");
this.headerTable.appendChild(this.headerBody);
- dojo.html.addClass(this.headerTable,"xapHeaderTable");
-
//now populate the header row
this.headerRow = document.createElement("tr");
this.headerBody.appendChild(this.headerRow);
for (var i = 0; i<this._columns.length; i++){
var cell = document.createElement("td");
dojo.html.addClass(cell,'xapHeaderWrapper');
-
+ this.headerRow.appendChild(cell);
cell.style.whiteSpace = "nowrap";
- // If overflow isn't hidden, then
- // column cannot be shrunk below
- // width of the contents:
- cell.style.overflow="hidden" ;
-
- var w = null ;
- var hasColumns = this._columns && this._columns[i] ;
- if(hasColumns){
- if(w=this._columns[i].getBestWidth()){
- cell.style.width = w ;
- }
- }
-
-
- this.headerRow.appendChild(cell);
-
-
- var header = null ;
- if (header = this._columns[i]._header){
- this._lastHeaderAdded = header ;
- var hAlign = this._columns[i]._horizontalAlignment ;
- if( !hAlign ){
- // Default alignment:
- hAlign = "left" ;
- }
- // This is another of our widgets, a Button
- // instance; in this case the sorting hint image
- // is _not_ a standard button image, since we
- // wish to reserve that place for some other image:
- header.setTextPlacementHorizontal(hAlign) ;
- if(header._rootDomNode){
- var subnode= header._rootDomNode ;
- subnode.style.overflow = "hidden" ;
- subnode.style.whitespace="nowrap" ;
- cell.appendChild(subnode);
- }
+ if (this._columns[i]._header && this._columns[i]._header._rootDomNode){
+ cell.appendChild(this._columns[i]._header._rootDomNode);
}
cell.style.visibility = this._headerVisibility;
-
}
if (this._headerVisibility=='hidden'){
@@ -593,39 +334,30 @@
this.headerDiv.style.visibility='hidden';
this.headerDiv.style.display='none';
}
-
},
/**
* Rebuilds the entire table from scratch
*/
- _rebuildTable: function(){ //debug::this.loggit('_rebuildTable') ;
+ _rebuildTable: function(){
var wh = dojo.html.getMarginBox(this.domNode);
//if we have no width wait for onResized()
if (!wh.width){
- if(this._rebuildTableTask){
- window.clearTimeout(this._rebuildTableTask);
- this._rebuildTableTask = null;
- }
+ window.clearTimeout(this._rebuildTableTask);
+ this._rebuildTableTask = null;
return;
}
this._initialResizePending = false;
this._rebuildHead();
this._rebuildBody();
-
- if( this._rebuildTableTask ){
- window.clearTimeout(this._rebuildTableTask);
- this._rebuildTableTask = null;
- }
+ window.clearTimeout(this._rebuildTableTask);
+ this._rebuildTableTask = null;
this._resizeTable();
-
- dojo.lang.setTimeout(this,this._renewColumnSizers,10) ;
},
-
- _rebuildRow: function( row, depth, alternateRow ){ //debug::this.loggit('_rebuildRow') ;
+ _rebuildRow: function( row, depth, alternateRow ){
this.tbody.appendChild(row.domNode);
row.setDepth(depth);
for (var i = 0; i<row._rows.length; i++){
@@ -637,7 +369,7 @@
//even if we expanded only the very last row. If we add/remove/expand/contract
//a row we only really need to start recoloring at that node
//TODO efficiency
- _recolorAlternateRows: function(){ //debug::this.loggit('_recolorAlternateRows') ;
+ _recolorAlternateRows: function(){
if (!this._alternateRowClass) return;
var alternateRow = false;
for (var i =0; i<this._rows.length; i++){
@@ -646,8 +378,7 @@
},
-
- _recolorRow: function( row, alternateRow ){ //debug::this.loggit('_recolorRow') ;
+ _recolorRow: function( row, alternateRow ){
if (alternateRow){
dojo.html.addClass(row.domNode,this._alternateRowClass);
}
@@ -664,297 +395,16 @@
}
return alternateRow;
},
-
- _isNotRoughedIn: function(){
- return !this.domNode
- ||!this.domNode.clientHeight
- || !this.domNode.clientWidth
- || !this.scrollDiv
- ||!this.scrollDiv.clientHeight
- || !this.scrollDiv.clientWidth
- || !this.table
- ||!this.table.clientHeight
- || !this.table.clientWidth ;
-
- },
-
- _hasScrollbar: function(){
- return this.scrollDiv.clientHeight - this.scrollDiv.offsetHeight ;
- },
/*
* Support for dynamic sizing
*/
- setHeight:function(aHeight){ //debug::this.loggit('setHeight') ;
- // If we don't have real (non-{zero-extent})
- // domNode/scrollDiv/table, don't bother yet
- // ---reschedule for a later time when
- // they've arrived.
- // TODO: Handle case where user _wants_
- // a zero-height or -width table:
- if ( this._isNotRoughedIn() ){
- // Don't reschedule another one if
- // one's there already:
- if( !this._setHeightTask ){
- this._setHeightTask
- = dojo.lang.setTimeout(this,this.setHeight,100,aHeight) ;
- }
- return ;
- }
-
- if( this._setHeightTask ){
- clearTimeout(this._setHeightTask) ;
- this._setHeightTask = null ;
- }
-
- this.scrollDiv.style.height="100%" ;
- this.scrollDiv.style.width="100%" ;
- this.scrollDiv.style.overflow="hidden" ;
-
- this.domNode.style.height = aHeight ;
- // Table style might have been at "100%" in width or height;
- // if that were so then when the scroll div were resized
- // the table would too, and so not overflow:
- if( this.table ){
- this.table.style.height=this.table.scrollHeight+"px";
- }
-
- this.scrollDiv.style.height
- = (this.domNode.offsetHeight
- - this.headerDiv.offsetHeight) +"px" ;
-
- this._resetScrollDivLater( this._resetScrollDivDelayMs ) ;
-
+ setHeight:function(value){
+ if (this.domNode) this.domNode.style.height = value;
+ this.onResized();
},
- _resetScrollDivLater: function(delay){ //debug::this.loggit('_rebuildTableLater') ;
-
- //cancel any partial rebuild tasks
- if (this._resetScrollDivTask){
- window.clearTimeout(this._resetScrollDivTask);
- this._resetScrollDivTask = null;
- }
-
- //if not already scheduled then schedule it
- var theDelay = delay || 0 ;
- if (!this._resetScrollDivTask){
- this._resetScrollDivTask
- = dojo.lang.setTimeout(this, this._resetScrollDiv, theDelay);
- }
- },
-
-
- _resetScrollDiv: function(){
- // Should probably be able to avoid this,
- // but this is doing it directly....
- var oBox = {} ;
- oBox.width = this.scrollDiv.clientWidth ;
- oBox.height = this.scrollDiv.clientHeight ;
-
- this.scrollDiv.style.overflow="auto" ;
- dojo.lang.setTimeout(
- this,
- this._finishScrollDiv,
- this._finishScrollDivDelayMs,
- oBox
- ) ;
- },
-
- _finishScrollDiv: function(originalScrollClientBox){
- var fBox = {} ;
- fBox.width = this.scrollDiv.clientWidth ;
- fBox.height = this.scrollDiv.clientHeight ;
-
- var deltaH = originalScrollClientBox.height - fBox.height ;
- var deltaW = originalScrollClientBox.width - fBox.width ;
-
- // If there's no set width,
- // make room for the scrollbar
- if( deltaW ){
- if(!this._tableLayoutModel.initialWidth
- && !this._tableLayoutModel.resetWidthPx
- ){
- var newWidthPx = this.scrollDiv.offsetWidth ;
- newWidthPx += deltaW ;
- this.domNode.style.width = newWidthPx + "px" ;
- }
- }
- //debugger;
- if( deltaH ){
- // If there's no set height,
- // make room for the scrollbar
- if( !this._tableLayoutModel.initialHeight
- && !this._tableLayoutModel.resetHeightPx
- ){
- var newHeightPx
- = this.scrollDiv.scrollHeight
- +this.headerDiv.clientHeight ;
-// if(dojo.render.html.ie){
-// newHeightPx += deltaH ;
-// }
- this.scrollDiv.style.height = newHeightPx +"px" ;
- }
- }
-
- // Redisplays headerDiv appropriately---fills in
- // square above right vertical scrollbar:
- this.onScrollCallback() ;
- this._renewColumnSizers() ;
- this._fixAllSizerWidthsAndPositions() ;
- },
-
- setWidth: function(aWidth){ //debug::this.loggit('setWidth') ;
- // If we don't have real (non-{zero-extent})
- // domNode/scrollDiv/table, don't bother yet
- // ---reschedule for a later time when
- // they've arrived.
- // TODO: Handle case where user _wants_
- // a zero-height or -width table:
-
-// Later: Screws up case where table width is greater than columns'
-// total width---adds all the width to the first column.
-// Right now, it looks like we can do without the waiting,
-// but in case that turns out differently.....
-// TODO: find out why height and width behave differently
-// TODO: reactivate this gate if needed, fix the screw-up
-// described above.
- if (this._isNotRoughedIn() ){
- // Don't reschedule another one if
- // one's there already:
- if( !this._setWidthTask ){
- this._setWidthTask
- = dojo.lang.setTimeout(this,this.setWidth,100,aWidth) ;
- }
- return ;
- }
-
- this.scrollDiv.style.overflow="hidden" ;
- //(Change back later.)
-
- // Table style might have been at "100%" in width or height;
- // if that were so then when the scroll div were resized
- // the table would too, and so not overflow:
- if( this.table ){
- var tableBox = dojo.html.getMarginBox(this.table) ;
- dojo.html.setMarginBox(this.table,tableBox) ;
- }
-
- var oWidth = (dojo.html.getContentBox(this.domNode)).width ;
- this.scrollDiv.style.width = "100%" ;
- this.domNode.style.width = aWidth ;
- var fWidth = (dojo.html.getContentBox(this.domNode)).width ;
-
-
- this._tableLayoutModel.resetWidthPx= fWidth ;
-
- // We no longer care what
- // the width initally was
- // ---unless we're not
- // really displaying yet,
- // in which case we have a
- // 0px value
- if( fWidth != 0 ){
- delete this._initialWidth ;
- } else {
- // if we're starting out and
- // we couldn't really set the
- // width at this point, make sure
- // that the next time we need to set
- // it, it will be held here:
- this._initialWidth = aWidth ;
- }
-
- var deltaPx = fWidth - oWidth ;
-
- if( deltaPx == 0 ){
- this._resetScrollDivLater(this._resetScrollDivDelayMs) ;
- return ;
- }
- if( deltaPx < 0){
- // any need to do anything else?
- this._resetScrollDivLater(this._resetScrollDivDelayMs) ;
- return ;
-
- }
-
- // widened dom node:
- if( !this.headerRow
- || !this.headerRow.childNodes
- || this.headerRow.childNodes.length == 0
- ){
- this._resetScrollDivLater(this._resetScrollDivDelayMs) ;
- return ;
- }
-
-
-
- if( deltaPx > 0 ){
- //widened:
- var w = fWidth + "px" ;
-
-// TODO: remove all the bits now made redundant by
-// _resetScrollDiv---or maybe rename that to onResized()
-
- this.table.style.width = "100%" ;
- var tableWidth = this.table.clientWidth +"px" ;
- this.table.style.width = tableWidth ;
-
- this.headerDiv.style.width = "100%" ;
- this.headerDiv.style.width = this.headerDiv.clientWidth +"px";
- this.headerTable.style.width = tableWidth ;
-// this.headerRow.style.width
-// = (this.getVerticalScrollbarWidthPx()+this.scrollDiv.scrollWidth) +"px" ;
-
- this.columnsSizer.paneWidth = fWidth ;
- this.columnsSizer.domNode.style.width = w ;
- this.extendLastColumn(deltaPx) ;
- }
-
- this._resetScrollDivLater(this._resetScrollDivDelayMs) ;
- },
-
- extendLastColumn: function(changeInPixels){ //debug::this.loggit('extendLastColumn') ;
-
- // Since their layout is fixed, this will mean that
- // the tables in question will end up as wide as their
- // columns (or first row cells, under IE) and borders
- // will need. If we don't do this, space ends up getting
- // added to or subtracted from (it seems) the first cell,
- // which ends up with a width of "100%":
- this.headerTable.style.tableLayout = "fixed" ;
- this.headerTable.style.width = "auto" ;
- this.table.style.width = "auto" ;
-
-
- var headerChildren = this.headerRow.childNodes ;
- var len = headerChildren.length ;
- var lastIdx = len - 1 ;
- if(len > 0){
- var newWidth = dojo.html.getMarginBox(headerChildren[len-1]).width ;
- newWidth += changeInPixels ;
- headerChildren[lastIdx].style.width = newWidth+"px";
-
- var sizer = this.columnsSizer ;
- // Put all the extra space in the last column:
- sizer.children[lastIdx].sizeShare = newWidth ;
- sizer.children[lastIdx].sizeActual = newWidth ;
- this._columns[lastIdx].setStatedWidth(newWidth) ;
- }
- // Match body to to them changed header column:
- this._fixColumnWidths(lastIdx,lastIdx) ;
-
-
- // Fix these widths (in the sense of "set them");
- // leaving them free seems to hurt scrolling:
- this.headerTable.style.width
- = this.headerTable.scrollWidth +"px" ;
- this.table.style.width
- = this.headerTable.scrollWidth +"px" ;
-
- this._renewColumnSizers();
- },
-
- _isResized: function(w, h){ //debug::this.loggit('_isResized') ;
+ _isResized: function(w, h){
// summary
// Test if my size has changed.
// If width & height are specified then that's my new size; otherwise,
@@ -976,82 +426,18 @@
return true;
},
- onResizedLater: function(delay){
- //if a resize is pending don't bother
- if (!this._onResizedTask ){
- var theDelay = delay || 0 ;
- this._onResizedTask
- = dojo.lang.setTimeout(this, this.onResized, delay);
- }
- },
-
- onResized:function(){ //debug::this.loggit('onResized') ;
- return ;
-// I think this has mostly been made redundant by code
-// in _resetScrollDiv
-// if ( !this.scrollDiv || !this.headerDiv){
-// return ;
-// }
-//
-// if( !this.domNode || !this.domNode.clientWidth
-// ||!this.domNode.clientHeight
-// ){
-// return ;
-// }
-//
-// //cancel any partial rebuild tasks
-// if (this._onResizedTask){
-// window.clearTimeout(this._onResizedTask);
-// this._onResizedTask = null;
-// }
-//
-//
-// if (this._initialResizePending && this.width) {
-// this._rebuildTableLater();
-// }
-//
-// // Table style might have been at "100%" in width or height;
-// // if that were so then when the scroll div were resized
-// // the table would too, and so not overflow:
-// if( this.table ){
-// var tableBox = dojo.html.getMarginBox(this.table) ;
-// dojo.html.setMarginBox(this.table,tableBox) ;
-// }
-//
-// /* recalculate the content scrollDiv */
-// var contentHt = "100%";
-// var ht = this.domNode.clientHeight - this.headerDiv.clientHeight;
-// if ( ht > 0 ){
-// contentHt = ht + "px";
-// }
-//
-// var scrollDivClientWidth = this.scrollDiv.clientWidth ;
-// this.scrollDiv.style.height = contentHt;
-//
-//
-// // We might've just clipped ~20px from the right
-// // of the table; in that case we might need an
-// // horizontal scrollbar:
-// if( scrollDivClientWidth > this.scrollDiv.clientWidth){
-// var contentWd = "100%";
-// var wd = this.scrollDiv.offsetWidth;
-// if ( wd > 0 ){
-// contentWd = wd + "px";
-// }
-// this.scrollDiv.style.width = contentWd ;
-// this.scrollDiv.style.height =
-// (this.scrollDiv.scrollHeight
-// - 20)+"px" ;
-// }
-// if( this.columnsSizer ){
-// this._renewColumnSizers() ;
-// }
-//
-// dojo.lang.setTimeout(this,this._resetScrollDiv,0) ;
-
+ onResized:function(){
+ if ( this.scrollDiv && this.headerDiv){
+ if (this._initialResizePending && this.width) {
+ this._rebuildTableLater();
+ }
+ /* recalculate the content scrollDiv */
+ var contentHt = "100%";
+ var ht = this.domNode.clientHeight - this.headerDiv.clientHeight;
+ if ( ht > 0 ) contentHt = ht + "px";
+ this.scrollDiv.style.height = contentHt;
+ }
},
-
-
/**
*
*
@@ -1060,7 +446,7 @@
*
*/
- insertColumn: function(column, index){ //debug::this.loggit('insertColumn') ;
+ insertColumn: function(column, index){
column.setTable(this);
if (index && index>=0){
@@ -1073,14 +459,14 @@
//more efficient by inserting the column in place
},
- removeColumn: function(column){ //debug::this.loggit('removeColumn') ;
+ removeColumn: function(column){
xap.util.ArrayHelper.removeElement (this._columns,column);
//TODO efficiency
this._rebuildTableLater();
},
//index here is relative to parent row?
- insertRow: function(row, index){ //debug::this.loggit('insertRow') ;
+ insertRow: function(row, index){
if (index && index>=0){
xap.util.ArrayHelper.insertElementAt(this._rows,row,index);
}
@@ -1091,12 +477,12 @@
this._rowAdded(row);
},
- removeRow: function( row ){ //debug::this.loggit('removeRow') ;
+ removeRow: function( row ){
xap.util.ArrayHelper.removeElement (this._rows,row);
this._rowRemoved(row);
},
- _rowAdded: function(row){ //debug::this.loggit('_rowAdded') ;
+ _rowAdded: function(row){
row.setTable(this);
//if the row starts as selected when it is added,
@@ -1114,21 +500,10 @@
//at the right spot. Gets kind of tricky for nested rows and such,
//in that case you need to insert relative to a sibling
// TODO: maybe resize the columns when stuff is added
-
- // TODO important: find out why the first row
- // added to an IE table created with no rows
- // gets messed-up column widths:
- if(!this._created
- || !dojo.render.html.ie
- ||this._rows.length>1
- ){
- this._rebuildRowsLater();
- } else {
- this._rebuildTableLater(500);
- }
+ this._rebuildRowsLater();
},
- _rowRemoved: function(row){ //debug::this.loggit('_rowRemoved') ;
+ _rowRemoved: function(row){
if (this.isSelected(row)){
xap.util.ArrayHelper.removeElement(this._selectedItems, row);
@@ -1149,66 +524,51 @@
* Row selection stuff
*/
- selectRow: function(row){ //debug::this.loggit(' selectRow') ;
+ selectRow: function(row){
if (this.isSelected(row)){
return false;
}
if (this._selectionMode=="singleRow"){
this.clearSelection();
}
- dojo.html.addClass(row.domNode,this._selectedRowClass);
+ dojo.html.addClass(row.domNode,"selectedRow");
this._selectedItems.push(row);
return true;
},
- // remove from selected items
- deselectRow: function(row) {
- var items = this._selectedItems;
- if(items.length === 0) { return; }
- for (var i = 0; i < items.length; i++) {
- if(items[i] == row) {
- dojo.html.removeClass(row.domNode, this._selectedRowClass);
- this.onDeselectRow(row);
- items.splice(i, 1);
- }
- }
- },
-
-
- selectRowByUser: function(row){ //debug::this.loggit(' selectRowByUser') ;
+ selectRowByUser: function(row){
if (this.selectRow(row)){
this.onSelectRow(row);
}
},
- onSelectRow : function(row){ //debug::this.loggit(' onSelectRow ') ;
+ onSelectRow : function(row){
//event hook
},
- clearSelection : function(){ //debug::this.loggit(' clearSelection ') ;
+ clearSelection : function(){
for (var i =0; i<this._selectedItems.length; i++){
- dojo.html.removeClass(this._selectedItems[i].domNode,this._selectedRowClass);
+ dojo.html.removeClass(this._selectedItems[i].domNode,"selectedRow");
this.onDeselectRow(this._selectedItems[i]);
}
this._selectedItems = [];
},
- activateRow: function(row){ //debug::this.loggit(' activateRow') ;
+ activateRow: function(row){
this.onActivateRow(row);
},
- onDeselectRow : function(row){ //debug::this.loggit(' onDeselectRow ') ;
+ onDeselectRow : function(row){
//event hook
},
- onActivateRow : function(row){ //debug::this.loggit(' onActivateRow ') ;
+ onActivateRow : function(row){
//event hook
},
- isSelected: function(row){ //debug::this.loggit(' isSelected') ;
- var result = xap.util.ArrayHelper.indexOf(this._selectedItems,row) >= 0;
- return result;
- },
+ isSelected: function(row){
+ return (xap.util.ArrayHelper.indexOf(this._selectedItems,row)>=0);
+ },
@@ -1218,35 +578,26 @@
*
*/
- onExpandRow : function(row, expanded){ //debug::this.loggit('onExpandRow ') ;
- this._recolorAlternateRows();
- this._redoSplitPanelStyling(1000) ;
- //event hook
- },
-
+ onExpandRow : function(row, expanded){
+ this._recolorAlternateRows();
+ //event hook
+ },
- onScrollCallback : function(event){ //debug::this.loggit('onScrollCallback ') ;
+ onScrollCallback : function(event){
if (this.scrollDiv){
- // We have a vertical scrollbar, adjust header to
- // look like it's to the left of it:
- this.headerDiv.style.width
- =(this.getVerticalScrollbarWidthPx()
- + this.scrollDiv.scrollWidth
- )+"px" ;
this.headerDiv.style.left = -this.scrollDiv.scrollLeft + "px";
- this.splitterContainer.style.left =this.headerDiv.offsetLeft+"px";
}
},
- sortColumn: function( column ){ //debug::this.loggit('sortColumn') ;
+ sortColumn: function( column ){
//blank out the sort icon on the column we previously sorted
if (this._lastSortedColumn && (this._lastSortedColumn != column)){
- this._lastSortedColumn.setSortNone() ;
- // Block resizing the table
- // as a result of this sort:
- this._justSorted = true ;
+ var oldHint = this._lastSortedColumn ._header.getImgHint();
+ dojo.html.removeClass(oldHint,'xapSortDescendingImage');
+ dojo.html.removeClass(oldHint,'xapSortAscendingImage');
+ dojo.html.addClass(oldHint,'xapSortNoneImage');
}
var dataType = column._dataType || "string";
@@ -1276,31 +627,23 @@
}
- var bSortAscending = !column._sort || column._sort=='descending' ;
-
//sort the array and change _rows to match
- this._rows.sort( sortFunction ) ;
+ this._rows.sort(sortFunction);
+
- if (bSortAscending){
- column.setSortAsc();
- // Block resizing the table
- // (in the rebuildRows op.)
- // as a result of this sort:
- this._justSorted = true ;
+ var headerHint = column._header.getImgHint();
+ if (!column._sort || column._sort=='descending'){
+ column._sort = "ascending";
+ dojo.html.removeClass(headerHint,'xapSortDescendingImage');
+ dojo.html.addClass(headerHint,'xapSortAscendingImage');
}
else{
- column.setSortDesc() ;
+ column._sort = "descending";
+ dojo.html.removeClass(headerHint,'xapSortAscendingImage');
+ dojo.html.addClass(headerHint,'xapSortDescendingImage');
this._rows.reverse();
-
- // Block resizing the table
- // (in the rebuildRows op.)
- // as a result of this sort:
- this._justSorted = true ;
-
}
-
-
// before we do anything set the widths of what will become the new first row of cells
// so IE won't freak out (fixed layout without fixed sizes in the first inserted row)
if (dojo.render.html.ie){
@@ -1311,7 +654,7 @@
this._rebuildRowsLater();
},
- _sortStringsFunction: function(a, b){ //debug::this.loggit('_sortStringsFunction') ;
+ _sortStringsFunction: function(a, b){
var aVal = a._sortValue.toLowerCase();
var bVal = b._sortValue.toLowerCase();
if (aVal==bVal) return 0;
@@ -1319,605 +662,13 @@
return 1;
},
- _sortNumbersFunction: function(a, b){ //debug::this.loggit('_sortNumbersFunction') ;
+ _sortNumbersFunction: function(a, b){
var aVal = a._sortValue;
var bVal = b._sortValue;
if (aVal==bVal) return 0;
if (aVal<bVal) return -1;
return 1;
- },
-
- _sizeSplitterContainer: function(){ //debug::this.loggit('_sizeSplitterContainer') ;
- var box = {} ;
-
- box.width = Math.max(this.domNode.scrollWidth,this.table.scrollWidth) ;
- box.height = this.headerTable.clientHeight ;
-
- dojo.html.setMarginBox(this.splitterContainer,box) ;
- },
-
- _addSplitterPane: function(aBox, lastPaneP){
- var widg = dojo.widget.createWidget("DivWrapper",aBox) ;
- // This is the proportion of the entire split
- // pane given over to this panel:
- var dom = widg.domNode ;
-
- widg.sizeShare = aBox.width ;
- this.columnsSizer.addChild( widg ) ;
- if( lastPaneP ){
- widg.sizeMin = 0 ;
- this._lastSplitterPane = widg.domNode ;
- }
- },
-
- // Add sizers for the columns that have just been built:
- // TODO: Re-write table so that the header is already
- // a split container instead of a table row---should make
- // things much simpler here:
- _renewColumnSizers: function(){ //debug::this.loggit('_renewColumnSizers') ;
- if( !this.headerDiv || !this._columns|| this._columns.length==0 ){
- return ;
- }
-
- var sizer = this.columnsSizer ;
- if( sizer ){
- dojo.event.disconnect(
- sizer,
- sizer.endSizing,
- this,
- this.onEndSizing
- ) ;
- dojo.event.disconnect(
- sizer,
- sizer.beginSizing,
- this,
- this.onBeginSizing
- ) ;
-
-
- if( this.splitterContainer ){
- this.splitterContainer.parentNode.removeChild(this.splitterContainer) ;
- }
- delete this.columnsSizer ;
- }
-
- this.splitterContainer
- = this.domNode.appendChild(document.createElement("div")) ;
- var splitterContainer = this.splitterContainer ;
- var splitterContainerStyle = splitterContainer.style ;
- splitterContainerStyle.position = "absolute" ;
- splitterContainerStyle.top = "0px" ;
-
- var box = {} ;
-
-
- this._sizeSplitterContainer() ;
-
-
-
- // Get a more accurate result with
- // a splitter width of 1px; make wider
- // at rest...
- this.columnsSizer =
- dojo.widget.createWidget(
- "SplitContainer",
- {
- height:1,
- width:box.width,
- sizerWidth:1,
- persist:false,
- activeSizing:false
- },
- splitterContainer
- );
-
- this._alterSizerMethods() ;
-
- splitterContainerStyle.zIndex = 0 ;
-
-
- var h = this.domNode.offsetHeight +"px" ;
-
- // Add a splitter panel for each header:
- for (var ii = 0; ii<this.headerRow.childNodes.length; ++ii){
- var node = this.headerRow.childNodes[ii] ;
- var box = dojo.html.getMarginBox(node) ;
- this._addSplitterPane(box) ;
- }
-
- // Add an additional panel for any space that might
- // exist between the last true column and the right
- // edge of the table:
- var box = {height: this.headerDiv.clientHeight,
- width: this.domNode.scrollWidth - this.headerTable.scrollWidth
- }
- this._addSplitterPane(box,true) ;
-
- this._lastSizer
- = this.columnsSizer.sizers[this.columnsSizer.sizers.length - 1] ;
-// This was recreating the sizers,producing too
-// many of them, and appears to be unneeded:
-// this.columnsSizer.postCreate() ;
-
- dojo.lang.setTimeout(this,this._applyBasicSizerStyling,0) ;
-
-
- //this.columnsSizer._layoutPanels();
-
-
-
- // Trigger out methods when the splitter
- // beings and ends dragging a sizer line:
- dojo.event.connect(
- this.columnsSizer,
- this.columnsSizer.endSizing,
- this,
- this.onEndSizing
- ) ;
- dojo.event.connect(
- this.columnsSizer,
- this.columnsSizer.beginSizing,
- this,
- this.onBeginSizing
- ) ;
- this._redoSplitPanelStyling();
-// dojo.lang.setTimeout(this,this.onEndSizing,200) ;
- this.onEndSizing();
- },
-
- _applyBasicSizerStyling: function(){
-
-// debug sizer vis:
-// var rainbow=["red","orange","yellow","green",
-// "blue","indigo","violet"
-// ] ;
-
- for( var idx = 0; idx < this.columnsSizer.sizers.length; ++idx){
-
- var aSizer = this.columnsSizer.sizers[idx] ;
-//*debug*/ aSizer.id = this.domNode.id + "_sizer_"+idx ;
-//*debug*/ aSizer.setAttribute("id",aSizer.id) ;
-//*debug*/ dojo.html.addClass(aSizer, "sizer_"+idx) ;
- aSizer.style.visibility="hidden" ;
- aSizer.style.height =
- /*(this.headerRow.clientHeight)*/0 +"px" ;
- dojo.html.removeClass(aSizer, "dojoSplitContainerSizerH") ;
- dojo.html.addClass(aSizer, "xapTableStationarySizers") ;
- // No need to see the sizers; they should
- // line up with the header boundaries
- // --if they're off by a lot (O(5px))
- // we'll care, but if they're off
- // by ~1px we're better off not seeing
- // them. Full accuracy is probably impossible
- // until the headerTable itself is made a
- // splitter container desendent:
- aSizer.style.visibility="visible" ;
-
-// debug sizer vis:
-// aSizer.style.backgroundColor =rainbow[idx] ;
-
-// debug sizer visibility by increasing opacity to (say) 30/0.3:
- if( dojo.render.html.ie ){
- aSizer.style.filter = "alpha(opacity=100)" ;
- } else {
- aSizer.style.opacity = 1.0 ;
- }
-
- this._fixSizerWidthAndPosition(idx) ;
-
- aSizer._xapReformatted = true ;
- }
-
- // splitters don't refresh properly on their
- // own once they're moved, under IE6/7:
- // (Later:) see similar problem under Firefox,
- // maybe this help there:
- this.onScrollCallback() ;
-
- },
-
- _fixSizerWidthAndPosition: function(index){
- var sizerNode = this.columnsSizer.sizers[index] ;
- var left = null ;
- if( index < this.headerRow.childNodes.length - 1 ){
- left
- = this.headerRow.childNodes[index+1].offsetLeft ;
- // under Firefox, looks like we're off by a border width
- // or something (margin?)
- if(dojo.render.html.moz){
- left += 1 ;
- }
- } else {
- // Pseudo-column at the end:
- left= this.headerRow.scrollWidth ;
- }
- // Now we're setting the sizer to be visible (see )
- // and it's only 1px wide; if we went back to the older way
- // (wider invisible sizers centred about the proper line)
- // we'll need that (width/2) factor---innoccuous now:
- sizerNode.style.left
- = (left -Math.floor(this._sizerWidth/2)) +"px";
- sizerNode.style.width=this._sizerWidth +"px" ;
- sizerNode.style.height = this.headerRow.clientHeight+"px";
- },
-
-
- _fixAllSizerWidthsAndPositions: function(index){
- // Readjust sizer handles to match
- // headers:
- if( !this.columnSizer ){
- return ;
- }
- var sizerHandles = this.columnSizer.sizers ;
- if( sizerHandles ){
- return ;
- }
-
- for(var kk=0; kk < sizerHandles.length ; ++kk){
- // Widen the sizers so they're more selectable:
- //---sizers behave more accurately when they're
- // slimmer, but are harder to select....
- this._fixSizerWidthAndPosition(kk) ;
- }
- },
-
-
- _redoSplitPanelStyling: function(delay){ //debug::this.loggit('_redoSplitPanelStyling') ;
- if( delay != undefined ){
- this._redoSplitPanelStylingTask
- = dojo.lang.setTimeout(this,this._redoSplitPanelStyling,delay) ;
- return ;
- }
- if( this._redoSplitPanelStylingTask ){
- window.clearTimeout(this._redoSplitPanelStylingTask) ;
- this._redoSplitPanelStylingTask = null ;
- }
-
- var sizer = this.columnsSizer ;
-
- if(!sizer ){
- return ;
- }
-
- var sizerDomNode = sizer.domNode ;
-
- this._sizeSplitterContainer() ;
- sizer.onResized(null) ;
-
- var sizerDivs = sizer.sizers ;
- var sizerPanes = sizer.children ;
-
- // We end up with superfluous sizers at the
- // end of the list; trim them:
- // TODO: Keep them from showing up in the
- // first place.
- var nColumns = this._columns.length ;
-
- if( nColumns==0 ){
- // No columns, no sizers:
- return ;
- }
-
- // One for each real inter-column border, one for the
- // border between the last column and the rightmost,
- // spacer, pseudo-column:
- var nSizers = nColumns ;
-
- var remainingWidthPx
- = this.columnsSizer.paneWidth ;
-
- for(var ii=0; ii<sizerPanes.length; ++ii){
- var sizerPane = sizerPanes[ii] ;
-
- if( this.headerRow.childNodes[ii] ){
- // This is a pane corresponding to a header cell:
- var w = dojo.html.getMarginBox(this.headerRow.childNodes[ii]).width ;
- sizerPane.sizeShare = w ;
- sizerPane.sizeActual = w ;
- sizerPane.domNode.style.width = (w)+"px" ;
- remainingWidthPx -= w ;
- } else {
- // this is the extra pane on the right
- sizerPane.sizeShare = remainingWidthPx ;
- sizerPane.sizeActual = remainingWidthPx ;
- sizerPane.domNode.style.width = (remainingWidthPx)+"px" ;
- }
- }
- sizer._layoutPanels() ;
-
- if( dojo.render.html.ie ){
- this._hideSplitterPanelsAndShowSizers(500) ;
- } else {
- this._hideSplitterPanelsAndShowSizers() ;
- }
- },
-
- _hideSplitterPanelsAndShowSizers: function(delay){ //debug::this.loggit('_hideSplitterPanelsAndShowSizers') ;
- if( delay != undefined ){
- this._hideSplitterPanelsAndShowSizersTask
- = dojo.lang.setTimeout(this,this._hideSplitterPanelsAndShowSizers,delay) ;
- return ;
- }
- // Don't bother if there are no columns or,
- // if we haven't built the full header row yet:
- //("this.columnsSizer.children.length-1" because
- // we have an extra split pane for the rightmost, spacer,
- // pseudo-column:
- if( !this._columns
- ||(this._columns.length==0)
- || (this._columns.length != (this.columnsSizer.children.length-1) )
- ){
- return ;
- }
-
- if( this._hideSplitterPanelsAndShowSizersTask ){
- window.clearTimeout(this._hideSplitterPanelsAndShowSizersTask ) ;
- this._hideSplitterPanelsAndShowSizersTask = null ;
- }
-
- this._applyBasicSizerStyling() ;
-
- // Figure out now if we'r in a browser
- // that will need an explicitly transparent
- // background colour---IE6 under XP
- var isXpIe6 =
- dojo.render.html.ie60 &&
- ( dojo.render.html.UA.indexOf("Windows NT 5.1") != -1 ) ;
-
- var sizer = this.columnsSizer ;
- var parent = this.columnsSizer.domNode ;
- var sizerHandles = sizer.sizers ;
- var splitterPanes = this.columnsSizer.children ;
- // Under Firefox and IE7, this is innocuous
- // and in fact necessary to get the splitter
- // dom node out of the way of the column headers.
- // under IE6 this screws up the sizing of
- // the splitter dom node, making it 0-by-0:
- if(!isXpIe6){
- parent.style.visibility = "hidden" ;
- }
-
-
- for(var ii=0; ii < this._columns.length; ++ii){
- var sizerHandle = sizerHandles[ii] ;
- var sizerHandleStyle = sizerHandle.style ;
- sizerHandleStyle.visibility = "visible" ;
- sizerHandleStyle.zIndex = 0 ;
-
-// Now, sizers are thin (1px) and visible:
-// if(isXpIe6){
-// /* Can't set it to "transparent" in CSS because
-// because that removes selectability under IE7;
-// ---instead, apply it in code to IE6/XP, which is
-// the only place it's needed,as the stylesheet's
-// {0 opacity} xor {alpha-filter stuff} works fine in Fire-
-// fox, IE7, and IE6/Win2K.
-// */
-// // To debug, you'll probably want to
-// // set this to something more noticeable:
-// sizerHandleStyle.backgroundColor="transparent" ;
-// }
- }
-
- var headers = this.headerRow.childNodes ;
- var totalSizeShare = 0 ;
- for(var jj=0; jj < headers.length; ++jj){
- var paneWidget = splitterPanes[jj] ;
- var paneStyle = paneWidget.domNode.style ;
- paneStyle.visibility="hidden" ;
- paneStyle.zIndex = 500 ;
- paneWidget.sizeShare
- = dojo.html.getMarginBox(headers[jj]).width ;
- paneWidget.sizeActual = paneWidget.sizeShare ;
- totalSizeShare += paneWidget.sizeShare ;
- }
- // style the spacer pane at the far right to avoid
- // a weird effect under ie that displays overflowed
- // text from the rightmost header
- // TODO: eliminate headerDiv, since this does
- // the same filling-in thing, more effectively?
- var paneWidget = splitterPanes[headers.length] ;
- var paneStyle = paneWidget.domNode.style ;
- paneStyle.visibility="visible" ;
- dojo.html.addClass(paneWidget.domNode,"xapHeaderBackground");
- paneStyle.zIndex = 0 ;
- paneWidget.sizeShare
- = this.splitterContainer.clientWidth
- - totalSizeShare ;
- paneWidget.sizeActual = paneWidget.sizeShare ;
-
- // Readjust sizer handles to match
- // headers:
- this._fixAllSizerWidthsAndPositions() ;
-
- sizer.virtualSizer.style.visibility = "visible" ;
- },
-
- onBeginSizing: function(e){ //debug::this.loggit('onBeginSizing') ;
-
-
- // Find out which sizer handle was grabbed:
- this._grabbedSizer = e.target ;
-
- var sizers = this.columnsSizer.sizers ;
- if( this._grabbedSizer == this._lastSizer ){
- this._lastTableRightPx
- = this._lastSizer.offsetLeft ;
- this._grabbedSizerIndex
- = sizers.length - 1 ;
- this._grabbedTheLastSizer = true ;
- } else {
- // Find which one we grabbed:
- var idx = -1 ;
- for( idx = -1 ; idx < sizers.length - 1; ++idx){
- if( sizers[idx] == this._grabbedSizer ){
- break ;
- }
- }
- this._grabbedSizerIndex = idx ;
- }
-
-
- var dragger = this.columnsSizer.virtualSizer ;
-
-
-
- dojo.html.removeClass( dragger, "dojoSplitContainerVirtualSizerH" ) ;
- dojo.html.addClass( dragger, "xapTableMovingSizer" ) ;
- // Can't cache: table height might changed
- dragger.style.height
- = (this.scrollDiv.offsetHeight + this.headerDiv.clientHeight)+"px" ;
- dragger.style.width = "1px" ;
- // Bring splitter container to front so
- // that we're not getting the column mouseover effects:
- this.splitterContainer.style.visibility = "visible" ;
- this.splitterContainer.style.overflow = "visible" ;
- },
-
- onEndSizing: function(e){ //debug::this.loggit('onEndSizing') ;
- dojo.html.removeClass( this.columnsSizer.virtualSizer, "xapTableMovingSizer" ) ;
- // Was set to "visible" to show taller-than-header dragging sizer:
- this.splitterContainer.style.overflow = "hidden" ;
-
- // user grabbed the last sizer:
- if( this._grabbedTheLastSizer && this._lastTableRightPx ){
-
- // The last sizer corresponds to a non-column;
- // it defines the right boundary of the table:
- var currentTableRightPx = this._lastSizer.offsetLeft ;
-
- var deltaTableRightPx
- = currentTableRightPx
- - this._lastTableRightPx ;
-
- // As soon as possible, avoid muddying the waters
- // for the next drag:
- delete this._lastTableRightPx ;
- delete this._grabbedSizerIndex ;
- delete this._grabbedTheLastSizer ;
-
- this.extendLastColumn(deltaTableRightPx) ;
-
- return ;
- }
- // else---all other sizers:
-//debug: alert("gsi: "+this._grabbedSizerIndex) ;
- if( this._grabbedSizerIndex > -1 ){
- dojo.lang.setTimeout(
- this,
- this._reconcileHeaderAndBodyColumns,
- 10,
- this._grabbedSizerIndex,
- this._grabbedSizerIndex + 1
- ) ;
- } else {
- // Can't identify the sizer grabbed:
- dojo.lang.setTimeout(
- this,
- this._reconcileHeaderAndBodyColumns,
- 10
- ) ;
- }
- },
-
- // With arguments, should only adjust the columns in the
- // range:
- _reconcileHeaderAndBodyColumns: function(pStartCol,pEndCol){ //debug::this.loggit('_reconcileHeaderAndBodyColumns') ;
-
-
- var startCol = 0 ;
- var endCol = this._columns.length - 1 ;
- if( pStartCol ){
- startCol = pStartCol ;
- if( pEndCol ){
- endCol = pEndCol ;
- }
- }
-
- if(!this.columnsSizer){
- this._fixColumnWidths();
- for (var i =0; i<this._rows.length; i++){
- this._rebuildRow(this._rows[i], 0);
- }
- return ;
- }
-
-
-
- this.columnsSizer._layoutPanels() ;
-
- // tell the columns how wide they ought to be:
- var children = this.columnsSizer.children ;
-
-//debug: alert(pStartCol+":"+pEndCol+"----"+startCol+":"+endCol) ;
- for(var ii=startCol ; ii < endCol+1; ++ii ){
-
- var w = children[ii].sizeShare ;
-
- var wPx = w +"px" ;
- this._columns[ii].setStatedWidth(w) ;
- this._columns[ii]._explicitColumnWidth = wPx ;
- dojo.html.setMarginBox(
- this._columns[ii].domNode,
- {width:w}
- ) ;
- dojo.html.setMarginBox(
- this.headerRow.childNodes[ii],
- {width:w}
- ) ;
- this.headerRow.childNodes[ii].style.overflow="hidden";
- }
-
-
-
-
- this._fixColumnWidths() ;
- //now repopulate the body rows using the good new columns:
- for (var i =0; i<this._rows.length; i++){
- this._rebuildRow(this._rows[i], 0);
- }
-
- // hide split panels, otherwise they'd
- // block mouse events to the column headers
- // they're over:
- this._hideSplitterPanelsAndShowSizers(10) ;
-
- } ,
-
-
- _alterSizerMethods: function(){
- this.columnsSizer._addSizer=function() {
- // Altered so that the sizer won't flash
- // as much on creation:
- var i = this.sizers.length;
-
- this.sizers[i] = document.createElement('div');
- this.sizers[i].style.position = 'absolute';
- /* Altered:*/
- this.sizers[i].style.height="1px" ;
- /* Altered. */
- this.sizers[i].className = this.isHorizontal ? 'dojoSplitContainerSizerH' : 'dojoSplitContainerSizerV';
-
- var self = this;
- var handler = (function(){ var sizer_i = i; return function(e){ self.beginSizing(e, sizer_i); } })();
- dojo.event.connect(this.sizers[i], "onmousedown", handler);
-
- this.domNode.appendChild(this.sizers[i]);
- dojo.html.disableSelection(this.sizers[i]);
- } ;
- this.columnsSizer.onResized = function(e){
- var content = dojo.html.getContentBox(this.domNode);
- this.paneWidth = content.width;
- // Alter this so we can have a drag-line
- // the height of the whole box, but not
- // the static sizer handles:
- //this.paneHeight = content.height;
- this._layoutPanels();
- } ;
-
- }
-
-
+ }
}
);
@@ -1940,66 +691,23 @@
templateCssPath: null ,
widgetType: "TableColumn",
isContainer: true,
- _horizontalAlignment: "left",
- ascImageUri:dojo.uri.moduleUri("xap","widgets/dojo/images/arrow_up.gif"),
- descImageUri:dojo.uri.moduleUri("xap","widgets/dojo/images/arrow_down.gif"),
- noneImageUri:dojo.uri.moduleUri("xap","widgets/dojo/images/spaced.gif"),
-
+
//we need this because setting the template string to
//<col></col> doesn't work for whatever reason,
//oversight in dojo code
fillInTemplate: function(args, frag){
this.domNode = document.createElement("col");
},
-
- setSortNone: function(){
- var xapLabel = this._header ;
- var oldHint = xapLabel.getImgHint();
- dojo.html.removeClass(oldHint,'xapSortDescendingImage');
- dojo.html.removeClass(oldHint,'xapSortAscendingImage');
- dojo.html.addClass(oldHint,'xapSortNoneImage');
- delete this._sort ;
- },
-
- setSortDesc: function( ){
- var xapLabel = this._header ;
- var oldHint = xapLabel.getImgHint();
- dojo.html.removeClass(oldHint,'xapSortNoneImage');
- dojo.html.removeClass(oldHint,'xapSortAscendingImage');
- dojo.html.addClass(oldHint,'xapSortDescendingImage');
- this._sort = "descending" ;
- },
-
- setSortAsc: function( ){
- var xapLabel = this._header ;
- var oldHint = xapLabel.getImgHint();
- dojo.html.removeClass(oldHint,'xapSortNoneImage');
- dojo.html.removeClass(oldHint,'xapSortDescendingImage');
- dojo.html.addClass(oldHint,'xapSortAscendingImage');
- this._sort = "ascending" ;
- },
-
setHeader: function( xapLabel ){
this._header = xapLabel;
- this.setSortNone();
+ dojo.html.addClass(xapLabel.getImgHint(),'xapSortNoneImage');
dojo.event.connect(xapLabel._rootDomNode, "onclick", this, "onClickCallback");
-
- // if there's an explicitly-set width in the header
- // then save it, else stick with any we might have got from XAL:
- if ( xapLabel._rootDomNode.style.width ){
+ // if there are explicit widths then save those
+ if ( xapLabel._rootDomNode.style.width )
this._headerWidth = xapLabel._rootDomNode.style.width;
- }
- // if no h-align stated, use column's if exists,
- // else default to "left":
- var hAlign = xapLabel._horizontalAlignment
- || this._horizontalAlignment
- || "left" ;
-
- dojo.lang.setTimeout(xapLabel,xapLabel.setAlignHorizontal,0,hAlign);
-
},
setTable: function(table){
@@ -2010,37 +718,7 @@
if (this._table){
this._table.sortColumn(this);
}
- },
-
- getStatedWidth: function(){
- return this._sStatedWidth ;
- },
-
- setStatedWidth: function(val){
- var res = val ;
- // We want a string value that
- // can be used to directly set
- // a style object member:
- if(!isNaN(val)){
- res += "px" ;
- }
- this._sStatedWidth = res ;
- },
-
- getBestWidth: function(){
- var res = this.getStatedWidth() ;
- if( !res ){
- // Use column width; if not set,
- // use header width:
- if( res = this._explicitColumnWidth ){
- } else if( res = this._headerWidth ){
- }
- }
- return res ;
}
-
-
-
});
@@ -2089,37 +767,21 @@
//thing, it should probably have something like:
//getText() function, domNode, getSortValue() function, etc,
//right now we don't have a good way of knowing what the text is
- addCell : function( cell , cellInfo, columnIndex){
+ addCell : function( cell , cellInfo){
this._cellInfo.push(cellInfo);
var td = document.createElement("td");
this.domNode.appendChild(td);
td.style.whiteSpace = "nowrap";
- td.style.overflow = "hidden";
- cell.style.whiteSpace = "nowrap";
- cell.style.overflow = "hidden";
-
- var hAlignment = null ;
- if ( cell.style.textAlign ) {
- hAlignment = cell.style.textAlign;
- } else {
- var col = this._table._columns[columnIndex] ;
- if(col){
- hAlignment = col._horizontalAlignment ;
- }
- }
-
- if( hAlignment ){
- td.align = hAlignment ;
- }
-
-
+ td.align="left";
td.valign = "top";
// read cell attributes and apply to the td
if ( cell.style.backgroundColor ){
td.style.backgroundColor = cell.style.backgroundColor;
}
-
+ if ( cell.style.textAlign ) {
+ td.align = cell.style.textAlign;
+ }
if (this._table && this._table._tableCellClass){
dojo.html.addClass(td,this._table._tableCellClass);
@@ -2129,8 +791,7 @@
//everywhere???
if (!this._indentSpan){
this._indentSpan = document.createElement("span");
- this._indentSpan.style.overflow= "hidden" ;
- this._indentSpan.style.whitespace= "nowrap" ; td.appendChild(this._indentSpan);
+ td.appendChild(this._indentSpan);
this._indentSpan.innerHTML = " ";
dojo.event.connect(this._indentSpan, "onclick", this, "onExpandCallback");
this._adjustImage();
@@ -2162,13 +823,13 @@
newClass = "ImgNodeCollapsed";
}
dojo.html.addClass(this._indentSpan, newClass);
- this._imageClass = newClass;
+ this._imageClass= newClass;
},
setDepth : function( depth ){
this._depth = depth;
if (this._indentSpan){
- this._indentSpan.style.marginLeft = (depth*12)+"px"; // width should be image + padding
+ this._indentSpan.style.marginLeft = (depth*10)+"px";
}
},
@@ -2193,20 +854,10 @@
// occurs
// ALSO we need to write back to the Xml element when the user selects or de-selects
// a row.
- if( (selected != this._lastSelected) ) {
- this._lastSelected = selected;
- if (this._table) {
- if(selected === true) {
- this._table.selectRow(this);
- return;
- }
- if(selected === false) {
- this._table.deselectRow(this);
- delete this._lastSelected;
- return;
- }
- }
- }
+ this._selected = selected;
+ if (this._table && selected){
+ this._table.selectRow(this);
+ }
},
//if we set to invis, set all children to invis as well
@@ -2262,94 +913,4 @@
}
}
-});
-
-
-
-
-
-
-//Debugging:
-/*
-xap.widgets.dojo.TreeTable.prototype.getWidths = function(){
-
- var s = "width\tdom\tscroll\ttable\ttbody\theaderDiv\theaderTable" ;
-
- s += "^style" ;
- s+= "\t"+this.domNode.style.width;
- s+= "\t"+this.scrollDiv.style.width;
- s+= "\t"+this.table.style.width;
- s+= "\t"+this.tbody.style.width;
- s+= "\t"+this.headerDiv.style.width;
- s+= "\t"+this.headerTable.style.width;
-
- s += "^client" ;
- s+= "\t"+this.domNode.clientWidth;
- s+= "\t"+this.scrollDiv.clientWidth;
- s+= "\t"+this.table.clientWidth;
- s+= "\t"+this.tbody.clientWidth;
- s+= "\t"+this.headerDiv.clientWidth;
- s+= "\t"+this.headerTable.clientWidth;
-
- s += "^offset" ;
- s+= "\t"+this.domNode.offsetWidth;
- s+= "\t"+this.scrollDiv.offsetWidth;
- s+= "\t"+this.table.offsetWidth;
- s+= "\t"+this.tbody.offsetWidth;
- s+= "\t"+this.headerDiv.offsetWidth;
- s+= "\t"+this.headerTable.offsetWidth;
-
- s += "^scroll" ;
- s+= "\t"+this.domNode.scrollWidth;
- s+= "\t"+this.scrollDiv.scrollWidth;
- s+= "\t"+this.table.scrollWidth;
- s+= "\t"+this.tbody.scrollWidth;
- s+= "\t"+this.headerDiv.scrollWidth;
- s+= "\t"+this.headerTable.scrollWidth;
-
-
- prompt("",s);
-
-}
-
-xap.widgets.dojo.TreeTable.prototype.getHeights = function(){
-
- var s = "height\tdom\tscroll\ttable\ttbody\theaderDiv\theaderTable" ;
-
- s += "^style" ;
- s+= "\t"+this.domNode.style.height;
- s+= "\t"+this.scrollDiv.style.height;
- s+= "\t"+this.table.style.height;
- s+= "\t"+this.tbody.style.height;
- s+= "\t"+this.headerDiv.style.height;
- s+= "\t"+this.headerTable.style.height;
-
- s += "^client" ;
- s+= "\t"+this.domNode.clientHeight;
- s+= "\t"+this.scrollDiv.clientHeight;
- s+= "\t"+this.table.clientHeight;
- s+= "\t"+this.tbody.clientHeight;
- s+= "\t"+this.headerDiv.clientHeight;
- s+= "\t"+this.headerTable.clientHeight;
-
- s += "^offset" ;
- s+= "\t"+this.domNode.offsetHeight;
- s+= "\t"+this.scrollDiv.offsetHeight;
- s+= "\t"+this.table.offsetHeight;
- s+= "\t"+this.tbody.offsetHeight;
- s+= "\t"+this.headerDiv.offsetHeight;
- s+= "\t"+this.headerTable.offsetHeight;
-
- s += "^scroll" ;
- s+= "\t"+this.domNode.scrollHeight;
- s+= "\t"+this.scrollDiv.scrollHeight;
- s+= "\t"+this.table.scrollHeight;
- s+= "\t"+this.tbody.scrollHeight;
- s+= "\t"+this.headerDiv.scrollHeight;
- s+= "\t"+this.headerTable.scrollHeight;
-
-
- prompt("",s);
-
-}
-*/
\ No newline at end of file
+});
\ No newline at end of file