Opened 12 years ago

Closed 11 years ago

#5250 closed defect (wontfix)

dojo.grid.data.Objects does not work well with editors

Reported by: guest Owned by: Bryan Forbes
Priority: high Milestone: 1.2
Component: DojoX Grid Version: 1.0
Keywords: grid exception copy objects dojox Cc: will@…, maciej.pestka@…
Blocked By: Blocking:

Description (last modified by Bryan Forbes)

I tried to get the grid to work with editors, and it threw an acception. I found out this was because it was using split(0) to copy the row. Since objects don't have a split method it raised an acception. Upon adding the function below to dojox.grid.data.Objects, the editor works normally, but the value in the grid does not change after editing. No exception was given.

copyRow: function(inRowIndex) {

var newRow = {};

var row = this.getRow(inRowIndex);

for (i in row) {

newRow[i] = row[i];

} return newRow;

}

Attachments (1)

dojo.grid.data.Objects.diff (1.4 KB) - added by guest 11 years ago.
finally the working patch if somebodu is interested…

Download all attachments as: .zip

Change History (8)

comment:1 Changed 11 years ago by dylan

Milestone: 1.2

comment:2 Changed 11 years ago by guest

I needed this too, so I found a quick fix (pointed by you in the right direction).
If it's correct may by it can make to 1.1?
Actually I copied some missing code from dojox.grid.data.DojoData
and added a setDatum method to update the data after editing.
This is the code that I use (it must be added to: dojo.grid.data.Objects)

// ****************************************************************************
...
//* Maciej Pestka modification, (code copied form dojox.grid.data.DojoData)
copyRow: function(inRowIndex){
	var row = {};
	var backstop = {};
	var src = this.getRow(inRowIndex);
	for(var x in src){
		if(src[x] != backstop[x]){
			row[x] = src[x];
		}
	}
	return row;
},
//* Maciej Pestka modification, (code copied form dojox.grid.data.DojoData)
_attrCompare: function(cache, data){
	dojo.forEach(this.fields.values, function(a){
		if(cache[a.name] != data[a.name]){ return false; }
	}, this);
	return true;
},
//* Maciej Pestka modification, (code copied form dojox.grid.data.DojoData)
endModifyRow: function(inRowIndex){
	var cache = this.cache[inRowIndex];
	if(cache){
		var data = this.getRow(inRowIndex);
		if(!this._attrCompare(cache, data)){
			this.update(cache, data, inRowIndex);
		}
		delete this.cache[inRowIndex];
	}
},
//* Maciej Pestka modification, (bugfix that updates appropriate field)
setDatum: function(inDatum, inRowIndex, inColIndex){
	this.data[inRowIndex][this.fields.get(inColIndex).key] = inDatum;
	this.datumChange(inDatum, inRowIndex, inColIndex);
},
...
// ****************************************************************************


I think the above code fixes this bug.

Regards
Maciej Pestka
maciej DOT pestka AT wp DOT pl

comment:3 in reply to:  description Changed 11 years ago by guest

Just found an additional bug in attributes comparison _attrCompare
Actually 2 bugs:

  1. the a.name shoule be replaced with a.key (as key is used in dojo.grid.data.Objects
  2. The false was never returned using _attrCompare code copied from dojox.grid.data.DojoData (does it mean that there is also bug in dojox.grid.data.DojoData._attrCompare???)

The code should be replaced with:

...
//* Maciej Pestka modification, (bugfix that compares attributes correctly)
_attrCompare: function(cache, data){
	var values = this.fields.values;
	for (var i in values){
		var v = values[i];
		if(cache[v.key] != data[v.key]){ 
			return false; 
		}
	}
	return true;
},
...

Maciej Pestka

PS.

How to setup email notification about the ticked updates?

Changed 11 years ago by guest

Attachment: dojo.grid.data.Objects.diff added

finally the working patch if somebodu is interested...

comment:4 Changed 11 years ago by Bryan Forbes

Cc: maciej.pestka@… added
Description: modified (diff)

Is this ticket still valid with the current trunk code?

comment:5 Changed 11 years ago by Bryan Forbes

Owner: changed from sorvell to Bryan Forbes

comment:6 Changed 11 years ago by Maciej Pestka

It's valid in 1.1.1 release. In the current trunk I could not find this file (seems like the folder structure is different and the declaration of dojo.grid.data.Objects is not available any more?)

comment:7 Changed 11 years ago by Bryan Forbes

Resolution: wontfix
Status: newclosed

dojox.grid.data.Objects is no longer supported (since we're not doing a bug fix release for 1.1.1). Because it is deprecated, we have written a porting guide: http://www.sitepen.com/blog/2008/07/14/dojo-12-grid . This should help with the transition to the new code base.

Note: See TracTickets for help on using tickets.