Opened 12 years ago

Closed 11 years ago

#5914 closed defect (fixed)

Column resizing with multiple header rows sometimes does not work.

Reported by: guest Owned by: nathan
Priority: high Milestone: 1.2
Component: DojoX Grid Version: 1.0
Keywords: Cc: houghtoj@…
Blocked By: Blocking:

Description (last modified by nathan)

The testGridGood.html test works. In it we defined a grid with two header rows:

  • the first row has four columns
  • the second row has four columns

I update the _findOverlappingNodes() method of the "dojox.grid.tableMap" class defined in dojox/grid/_grid/builder.js as follows to add four console.debug lines:

	_findOverlappingNodes: function(inTable, inRow, inCol){
	    console.debug( "=====> builder.js: _findOverlappingNodes(): 01: inRow = " + inRow + "; inCol = " + inCol + "." );
		var nodes = [];
		var m = this.getMapCoords(inRow, inCol);
	    console.debug( "=====> builder.js: _findOverlappingNodes(): 02: m = " + dojo.toJson( m ) + "." );
		//console.log("node j: %d, i: %d", m.j, m.i);
		var row = this.map[m.j];
	    console.debug( "=====> builder.js: _findOverlappingNodes(): 03: i = " + ( typeof i !== "undefined" ? i : "?" ) + "; j = " + ( typeof j !== "undefined" ? j : "?" ) + "; m.i = " + ( typeof i !== "undefined" ? m.i : "?" ) + "; m.j = " + ( typeof j !== "undefined" ? m.j : "?" ) + "; row = " + dojo.toJson( row ) + "." );
		for(var j=0, row; (row=this.map[j]); j++){
	        console.debug( "=====> builder.js: _findOverlappingNodes(): 04: i = " + ( typeof i !== "undefined" ? i : "?" ) + "; j = " + ( typeof j !== "undefined" ? j : "?" ) + "; m.i = " + ( typeof i !== "undefined" ? m.i : "?" ) + "; m.j = " + ( typeof j !== "undefined" ? m.j : "?" ) + "; row = " + dojo.toJson( row ) + "." );
			if(j == m.j){ continue; }
	        console.debug( "=====> builder.js: _findOverlappingNodes(): 05: i = " + ( typeof i !== "undefined" ? i : "?" ) + "; j = " + ( typeof j !== "undefined" ? j : "?" ) + "; m.i = " + ( typeof i !== "undefined" ? m.i : "?" ) + "; m.j = " + ( typeof j !== "undefined" ? m.j : "?" ) + "; row = " + dojo.toJson( row ) + "." );
			with(row[m.i]){
				//console.log("overlaps: r: %d, c: %d", r, c);
				var n = this.getNode(inTable, r, c);
				if(n){ nodes.push(n); }
			}
		}
		//console.log(nodes);
		return nodes;
	},

If I run this test case and click on the divider on the second row between the last two columns, here is what I see:

  =====> builder.js: _findOverlappingNodes(): 01: inRow = 1; inCol = 2.builder.js (line 411)
  =====> builder.js: _findOverlappingNodes(): 02: m = {"j": 1, "i": 2}.builder.js (line 414)
  =====> builder.js: _findOverlappingNodes(): 03: i = ?; j = ?; m.i = ?; m.j = ?; row = [{"c": 0, "r": 1}, {"c": 1, "r": 1}, {"c": 2, "r": 1}, {"c": 3, "r": 1}].builder.js (line 417)
  =====> builder.js: _findOverlappingNodes(): 04: i = ?; j = 0; m.i = ?; m.j = 1; row = [{"c": 0, "r": 0}, {"c": 1, "r": 0}, {"c": 2, "r": 0}, {"c": 3, "r": 0}].builder.js (line 419)
  =====> builder.js: _findOverlappingNodes(): 05: i = ?; j = 0; m.i = ?; m.j = 1; row = [{"c": 0, "r": 0}, {"c": 1, "r": 0}, {"c": 2, "r": 0}, {"c": 3, "r": 0}].builder.js (line 421)
  =====> builder.js: _findOverlappingNodes(): 04: i = ?; j = 1; m.i = ?; m.j = 1; row = [{"c": 0, "r": 1}, {"c": 1, "r": 1}, {"c": 2, "r": 1}, {"c": 3, "r": 1}].

Note that i and j are undefined, yet used. However, everything seems to work ok.

The testGridBad.html test works. In it we defined a grid with two header rows:

  • the first row has four columns
  • the second row has three columns (the first column spans two columns)

Note that the fact that there is a column that spans two columns makes a difference, as does having at least 4 columns in one row.

With the same console.debug lines above, if I again click on the divider on the second row between the last two columns, here is what I see:

  =====> builder.js: _findOverlappingNodes(): 01: inRow = 1; inCol = 1.builder.js (line 411)
  =====> builder.js: _findOverlappingNodes(): 02: m = {"j": -1, "i": -1}.builder.js (line 414)
  =====> builder.js: _findOverlappingNodes(): 03: i = ?; j = ?; m.i = ?; m.j = ?; row = undefined.builder.js (line 417)
  =====> builder.js: _findOverlappingNodes(): 04: i = ?; j = 0; m.i = ?; m.j = -1; row = [{"c": 0, "r": 0}, {"c": 1, "r": 0}, {"c": 2, "r": 0}, {"c": 3, "r": 0}].builder.js (line 419)
  =====> builder.js: _findOverlappingNodes(): 05: i = ?; j = 0; m.i = ?; m.j = -1; row = [{"c": 0, "r": 0}, {"c": 1, "r": 0}, {"c": 2, "r": 0}, {"c": 3, "r": 0}].builder.js (line 421)
  row[m.i] has no properties

Note that i and j are still undefined, yet used. However, in this case I get the javascript error above and the resizing of the column does not work.

If I click on the divider on the first row between the last two columns, here is what I see:

  =====> builder.js: _findOverlappingNodes(): 01: inRow = 0; inCol = 2.builder.js (line 411)
  =====> builder.js: _findOverlappingNodes(): 02: m = {"j": 0, "i": 2}.builder.js (line 414)
  =====> builder.js: _findOverlappingNodes(): 03: i = ?; j = ?; m.i = ?; m.j = ?; row = [{"c": 0, "r": 0}, {"c": 1, "r": 0}, {"c": 2, "r": 0}, {"c": 3, "r": 0}].builder.js (line 417)
  =====> builder.js: _findOverlappingNodes(): 04: i = ?; j = 0; m.i = ?; m.j = 0; row = [{"c": 0, "r": 0}, {"c": 1, "r": 0}, {"c": 2, "r": 0}, {"c": 3, "r": 0}].builder.js (line 419)
  =====> builder.js: _findOverlappingNodes(): 04: i = ?; j = 1; m.i = ?; m.j = 0; row = [{"c": 0, "r": 1}, {"c": 0, "r": 1}].builder.js (line 419)
  =====> builder.js: _findOverlappingNodes(): 05: i = ?; j = 1; m.i = ?; m.j = 0; row = [{"c": 0, "r": 1}, {"c": 0, "r": 1}].builder.js (line 421)
  row[m.i] has no properties

The odd part here is that the map for row 1 contains only two entries (I would have assumed three). Again, I get the javascript error above and the resizing of the column does not work.

A final problem is that if I attempt to resizing columns by clicking on the divider on the second row between the first two columns (the spanned column being the first one), the mouse indicator changes to the circle with the line through it indicating that I cannot resize the column.

The problem occurs on IE 6.0 and FF 2.0.

Attachments (3)

TestGridGood.html (2.8 KB) - added by guest 12 years ago.
Test case with no errors
TestGridBad.html (2.7 KB) - added by guest 12 years ago.
Test case with errors
testdata.txt (931 bytes) - added by guest 12 years ago.
Sample data store file for both test cases

Download all attachments as: .zip

Change History (6)

Changed 12 years ago by guest

Attachment: TestGridGood.html added

Test case with no errors

Changed 12 years ago by guest

Attachment: TestGridBad.html added

Test case with errors

Changed 12 years ago by guest

Attachment: testdata.txt added

Sample data store file for both test cases

comment:1 Changed 12 years ago by dylan

Milestone: 1.2

comment:2 Changed 11 years ago by nathan

Description: modified (diff)
Owner: changed from sorvell to nathan

comment:3 Changed 11 years ago by Nathan Toone

Resolution: fixed
Status: newclosed

(In [13887]) Fixes #5914. Check validity of row before using it. !strict

Note: See TracTickets for help on using tickets.