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

    1. Ext.define('MyApp.model.Movie', {
    2. extend: 'Ext.data.Model',
    3. fields: [{
    4. name: 'id',
    5. mapping: 'id.attributes["im:id"]'
    6. }, {
    7. name: 'movie',
    8. mapping: '["im:name"].label'
    9. }, {
    10. name: 'image',
    11. mapping: '["im:image"][2].label'
    12. }],
    13. proxy: {
    14. type: 'jsonp',
    15. url: 'https://itunes.apple.com/us/rss/topmovies/limit=5/json',
    16. reader: {
    17. type: 'json',
    18. rootProperty: 'feed.entry'
    19. }
    20. }
    21. });
    22. Ext.define('MyApp.view.Main', {
    23. extend: 'Ext.view.View',
    24. store: {
    25. model: 'MyApp.model.Movie',
    26. autoLoad: true
    27. },
    28. itemTpl: '<img src="{image}">',
    29. cls: 'movies',
    30. itemCls: 'movie',
    31. overItemCls: 'over',
    32. selectedItemCls: 'selected',
    33. emptyText: 'An Internet connection is needed to load titles from iTunes.'
    34. });
    35. Ext.application({
    36. name: 'MyApp',
    37. mainView: 'MyApp.view.Main'
    38. });