Sencha Touch - Aliases for model field names
I have a bunch of code for viewing data from a Store that I want to use across multiple applications with minimal changes; however, the data is being loaded from a different REST service depending on the application, and the services sometimes have different names for the same field.
Is there any way I can tell the Store, Proxy, Model, Field, or something else to use an "alias" to get around this problem? As in, I want a field named "city", but when the store loads its data, it assigns to "city" the data from the field "p开发者_StackOverflow中文版r_city" in the JSON response.
My response looks like this:
{
"d" : [
{ pr_city: "Denver", ... },
{ pr_city: "Chicago", ... },
{ pr_city: "Miami", ... }
]
}
Turns out there is a "mapping" property in the config for field objects.
fields = [
{ name: 'city', mapping: 'pr_city' }
]
found it in Sencha Touch - How to get list itemtpl to display JSON child objects?, credit to Evan Trimboli.
精彩评论