Results 1 to 2 of 2

Thread: Model associations via associative arrays/maps/hashes

  1. #1
    Sencha Premium Member twasink's Avatar
    Join Date
    Oct 2012
    Location
    Brisbane, Australia
    Posts
    122
    Vote Rating
    17
      0  

    Default 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 - Documentation Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,162
    Vote Rating
    257
      0  

    Default

    Thanks for sharing!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •