ExtJS 4 belongsTo Association
I could well just be dumb, but it seems associations in ExtJS 4 are broken. Following the documentation will only lead to confusion and wasted time. So, after much step-through debugging of the Ext source here's the minimal config that allows me to turn some JSON like this...
{
success: true,
items: [
{
id: 1,
relation: { id: 1, name: 'Relation' }
}
]
}
Into actually parsed models...
Ext.define('App.data.MyModel', {
extend: 'Ext.data.Model',
associations: [
{
type: 'belongsTo',
model: 'App.data.MyRelation',
associationName: 'relation',
getterName: 'getRelation'
}
]
}
Then go define your App.data.MyRelation model too obv. Phew...
Written by Rhodri Pugh
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Extjs
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#