-
20 Dec 2012 3:15 AM #1
Unanswered: Model save() method not dealing with mappings
Unanswered: Model save() method not dealing with mappings
Hello,
I'm working with a model that use a mapping, and I'm seeing a different behavior with GET and POST, with POST not getting all data.
Here's the simplified version of my model:
When calling MyMessage.load(<id>), the "author.id" field works fine.Code:Ext.define('MyMessage', { extend: 'Ext.data.Model', config: { fields: [ { name: 'id', type: 'int' }, { name: 'title', type: 'string' }, { name: 'body', type: 'string' }, ], associations: [ { type: 'belongsTo', model: 'MyUser', foreignKey: 'author.id' }, ] } });
But then if I call:
The record is saved, the local client data is updated except for the "author.id" association, which is undefined. Even tough the data returned from the server has the "author" object inside.Code:var newMsg = Ext.create('MyMessage', { title: 'MyTitle', body: 'MyBody' }); newMsg.save();
Is that normal?Last edited by Tegola; 20 Dec 2012 at 3:52 AM. Reason: Spelling
-
20 Dec 2012 3:57 AM #2
I don't see in your code where you tell newMessage who the author of the message is?
-
20 Dec 2012 4:01 AM #3
You're right, that's because I'm logged in and the server knows who is the author. Rest assured, the author object is there:
Code:{ "message": { "id": "125", "title": "MyTitle", "body": "MyBody", "author": { "id": "2", "name": "User name", "email": "user@email.com" } } }
-
20 Dec 2012 4:08 AM #4
Also, the latest reader data (newMsg.getProxy().getReader().metaData) contains the right data.
I'm stuck :|
-
21 Dec 2012 12:15 AM #5
I've studied the entire Ext.data section and I couldn't find a solution.
Do somebody have any clue?


Reply With Quote