Opened 9 years ago

Closed 9 years ago

#12646 closed defect (fixed)

EnhancedGrid indirectSelection plugin throws error when the formatterScope is specified

Reported by: james_cantwell Owned by: evan
Priority: high Milestone: 1.7
Component: DojoX Grid Version: 1.6.0
Keywords: EnhancedGrid indirectSelection Cc:
Blocked By: Blocking:

Description

When using the indirectSelection plugin with the EnhancedGrid? an error is throw when the formatterScope parameter is passed to the grid constructor.

 var grid = new dojox.grid.EnhancedGrid({
				  store: jsonStore,
				  rowSelector: '0px',
				  structure: gridStructure,
				  autoHeigth : '10',
				  formatterScope : this,
				  plugins: {indirectSelection: {headerSelector:true, name: "Selection", width: "10%", styles: "text-align: center;"}}
			  });

The error is thrown on line 139 of the IndirectSelection?.js file where the formatter function of dojox.grid.cells.RowSelector? assumes the scope to be the RowSelector? widget instead of the object passed into EnhancedGrid? constructor.

The attached grid.html file provides a simple test case. This was not a problem in version 1.5

Attachments (1)

grid.html (2.9 KB) - added by james_cantwell 9 years ago.
EnhancedGrid? formatter test case

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by james_cantwell

Attachment: grid.html added

EnhancedGrid? formatter test case

comment:1 Changed 9 years ago by shawnzhu

The root cause is rowSelector fails to find correct formatter scope. I dig into the code of the new indirectSelection code and found it assumes the scope of formatter function is always the rowSelector itself, where it is not actually when you specified the formatter scope to grid.

Here's a fix to dojox/grid/enhanced/plugins/IndirectSelection.js:

formatter: function(data, rowIndex, selector){
		// summary:
		//		Overwritten, see dojox.grid.cells._Widget
		var clazz = selector.baseClass;
		var checked = selector.getValue(rowIndex);
		var disabled = !!selector.disabledMap[rowIndex];//normalize 'undefined'
		
		if(checked){
			clazz += selector.checkedClass;
			if(disabled){ clazz += selector.checkedDisabledClass; }
		}else if(disabled){
			clazz += selector.disabledClass;
		}
		return ["<div tabindex = -1 ",
				"id = '" + selector.grid.id + "_rowSelector_" + rowIndex + "' ",
				"name = '" + selector.grid.id + "_rowSelector' class = '" + clazz + "' ",
				"role = 'presentation' aria-pressed = '" + checked + "' aria-disabled = '" + disabled +
				"' aria-label = '" + dojo.string.substitute(selector.grid._nls["indirectSelection" + selector.inputType], [rowIndex + 1]) + "'>",
				"<span class = '" + selector.statusTextClass + "'>" + (checked ? selector.checkedText : selector.unCheckedText) + "</span>",
				"</div>"].join("");
	},

I will submit a patch when I know how

comment:2 Changed 9 years ago by evan

Milestone: tbd1.7
Priority: normalhigh

comment:3 Changed 9 years ago by evan

Resolution: fixed
Status: newclosed

(In [25455]) Fixes #12646 by using correct formatting scope

Note: See TracTickets for help on using tickets.