1. #1
    Sencha Premium Member
    Join Date
    Oct 2012
    Posts
    15
    Vote Rating
    0
    twasink is on a distinguished road

      0  

    Default Model associations via associative arrays/maps/hashes

    Model associations via associative arrays/maps/hashes


    Sometimes, when working with JSON data, you don't get the format you want. In particular, it's not uncommon to see nested JSON data expressed as an object, instead of arrays. For example:

    Code:
    [
      { "id": "foo_1", "baz": "baz_1", "bux": "bux_1", "bar": {
          "bar_1": { "baz": "bar_baz_1", "bux": "bar_bux_1" },
          "bar_2": { "baz": "bar_baz_2", "bux": "bar_bux_2" }
        }
      },
      { "id": "foo_2", "baz": "baz_2", "bux": "bux_2", "bar": {
          "bar_1": { "baz": "bar_baz_3", "bux": "bar_bux_3" },
          "bar_2": { "baz": "bar_baz_4", "bux": "bar_bux_4" }
        }
      }
    ]
    ExtJS models can't read this out of the box. But it's possible to add a custom reader to your associations which can.

    See this Gist: https://gist.github.com/twasink/5392441
    or my blog post: http://twasink.net/2013/04/16/readin...-extjs-models/

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    2,257
    Vote Rating
    64
    slemmon is just really nice slemmon is just really nice slemmon is just really nice slemmon is just really nice slemmon is just really nice

      0  

    Default


    Thanks for sharing!