I'm trying to read entities from a Drupal Services endpoint into my Sencha Touch 2 application. The JSON output looks like this (simplified):
{
nid: 1
title: 'Test'
body: {
'en': [
'This is a test.'
]
}
}
Thats the model's coffeescript code:
Ext.define 'Node',
extend: 'Ext.data.Model'
config:
idProperty: 'nid'
fields: [
{ name: 'nid', type: 'integer' }
{ name: 'title', type: 'string' }
{ name: 'language', type: 'string' }
{ name: 'body', type: 'auto', convert: convertField }
]
proxy:
type: 'jsonp'
url: 'http://www.mydomain.com/rest/node'
convertField = (value, record) ->
console.log value # always "undefined"
return 'test'
Loading the model with a jsonp proxy works, but only the atomic fields (like "nid" and "title") are populated. I tried to add a "convert" function to the models body
field, but the value
parameter is always undefined.
Is there a way to load complex json data into a models field? Or do I have to use the Model-relations system (which would be a lot of mess ...). I also thought about overriding a Ext.data.Reader, but i don't really know where to start.