View Full Version : How to most effectivly deal with mixed model types in the same JSON request

19 Oct 2013, 8:53 AM
I have a API that is aggregating a number of different record types, and exposing them via a singe API call (GET only, don't need to worry about writing back to the server). The data basically looks something like this:

"name":"A record",
"......fields that only exist in record-type 1"
"name":"Another record",
"......fields that only exist in record-type 2"

It's important to note that the two types or models both have their own nested structures as well. A typical document might be a meg or two of data.

What's the most effective way to handle this? I'm a total newbie with EXT-JS, but as I understand it, each model is only designed for one model type, which means that overriding readRecords (which is what I am currently doing to deal with the fact that the data is coming to me a in associative array rather then a array) wont' work. Do I need to basically do all the parsing/reading myself, and write them to a in-memory store?


21 Oct 2013, 1:28 AM
Yes, you will need to do this, but maybe models' Readers (http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.reader.Reader-method-extractData) can hep you a bit.