PDA

View Full Version : [CLOSED][3.1] Ext.data.DataReader "Update" method



cumpa
5 Feb 2010, 7:42 AM
Ext version tested:
3.1.0

Description:
If fields in new data contain default values, same fields in record are not updated.

Test case:
Local record:



rs = {
data: {
firstField: 'firstValue',
secondField: 'secondValue'
}
}


After updating data, server response object is:


data = {
firstField: 'firstValue',
secondField: ''
}


Here is the code of "Update" method of Ext.data.DataReader:



update : function(rs, data) {
if (Ext.isArray(rs)) {
for (var i=rs.length-1; i >= 0; i--) {
if (Ext.isArray(data)) {
this.update(rs.splice(i,1).shift(), data.splice(i,1).shift());
}
else {
// weird...rs is an array but data isn't?? recurse but just send in the whole data object.
// the else clause below will detect !this.isData and throw exception.
this.update(rs.splice(i,1).shift(), data);
}
}
}
else {
// If rs is NOT an array but data IS, see if data contains just 1 record. If so extract it and carry on.
if (Ext.isArray(data) && data.length == 1) {
data = data.shift();
}
if (this.isData(data)) {
rs.fields.each(function(f) {
if (data[f.name] !== f.defaultValue) { <-- Field "secondField" not updated because new data is ''
rs.data[f.name] = data[f.name];
}
});
}
rs.commit();
}
},

evant
7 Feb 2010, 7:57 PM
Thanks for the report, we already have a ticket open for it: http://www.extjs.com/forum/showthread.php?t=89479