-
14 Jun 2011 5:08 AM #1
Ext.data.writer.Writer - data[record.idProperty]
Ext.data.writer.Writer - data[record.idProperty]
4.0.1 and 4.0.2
The documentation for idProperty clearly states that "The name of the field treated as this Model's unique id (defaults to 'id').".
This basically ignores any mapping defined in the field.Code:getRecordData: function(record){ .... if(!isPhantom){ // always include the id for non phantoms data[record.idProperty] = record.getId(); } }
I did this quick'n'dirty fix to make it work in the writer we already had to create because attribute-mapping fails (<@id>blah</@id>):
Code:data[fields.get(record.idProperty).mapping || record.idProperty] = record.getId();
Founder of the Path of Exticism
-
16 Jun 2011 3:04 AM #2
bumping for confirmation
Founder of the Path of Exticism
-
22 Jun 2011 11:37 AM #3
Im running into this same exact problem.
ColdFusion loves to spit out UPPERCASE fields, so I have to re-map everything as such
This does work in the sense that the ID is properly set on the record and phantom is set to false, (so I could theoretically call record.id), but calls to record.getId() fail because its looking for a field named ID in my model - that doesnt exist.....Code:... idProperty: 'ID', fields: [ {name: 'id', type: 'int', mapping: 'ID'}, ...
Maybe a workaround could be to reset the idProperty of the model to the mapped fieldafter the model has been loaded?
-
18 Jun 2012 2:13 AM #4
Hi,
The suggested fix is a bit buggy, because if nameProperty is not set to 'mapping', even than it uses the mapping for the id property.
So, I'd suggest this bugfix:
Bug is also present in 4.1.1 RC2!!!! Easy to fix, so go ahead guys!Code:Ext.override(Ext.data.writer.Writer, { getRecordData: function(record) { var isPhantom = record.phantom === true, writeAll = this.writeAllFields || isPhantom, nameProperty = this.nameProperty, fields = record.fields, data = {}, changes, name, field, key; if (writeAll) { fields.each(function(field){ if (field.persist) { name = field[nameProperty] || field.name; data[name] = record.get(field.name); } }); } else { // Only write the changes changes = record.getChanges(); for (key in changes) { if (changes.hasOwnProperty(key)) { field = fields.get(key); name = field[nameProperty] || field.name; data[name] = changes[key]; } } if (!isPhantom) { // always include the id for non phantoms switch(this.nameProperty){ case 'name': data[record.idProperty] = record.getId(); break; case 'mapping': //We make sure, that the mapping exists, //if not, we fall back to the idProperty. var idName = record.fields.get(record.idProperty).mapping || record.idProperty; data[idName] = record.getId(); break; } } } return data; } });
-
4 Oct 2012 2:28 AM #5
Hi,
This issue still seems to be there in EXT 4.1.2a release. Should I file a correct bug report on it? It's an incredibly easy fix, can't understand why it was not done so far.
-
13 Feb 2013 2:14 AM #6
Hi!
Still present in 4.1.3... Code does not work as expected if nameProperty config is set for the writer. Is it so hard to copy-paste a solution into the framework code, or what?
You found a bug! We've classified it as
a bug in our system.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote