Guide applies to: modern
The field class has a mapping config that lets you map the name of the field to the location of the value in the object.
Expand Code
JS Run
Ext.define('MyApp.model.Movie', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
mapping: 'id.attributes["im:id"]'
}, {
name: 'movie',
mapping: '["im:name"].label'
}, {
name: 'image',
mapping: '["im:image"][2].label'
}],
proxy: {
type: 'jsonp',
url: 'https://itunes.apple.com/us/rss/topmovies/limit=5/json',
reader: {
type: 'json',
rootProperty: 'feed.entry'
}
}
});
Ext.define('MyApp.view.Main', {
extend: 'Ext.view.View',
store: {
model: 'MyApp.model.Movie',
autoLoad: true
},
itemTpl: '<img src="{image}">',
cls: 'movies',
itemCls: 'movie',
overItemCls: 'over',
selectedItemCls: 'selected',
emptyText: 'An Internet connection is needed to load titles from iTunes.'
});
Ext.application({
name: 'MyApp',
mainView: 'MyApp.view.Main'
});