PDA

View Full Version : JSONP Proxy unable to access objects



tacitus
27 Aug 2012, 11:14 PM
I am using a 3rd party API to access some data. The structure of the data returned is slightly unusual:



{

matches:
{

from: 0,
count: 20,
total: 266,
matched_items:
[


{

stock:
{

code: "ABA",
exchange: "NZX",
name: "Abano Healthcare Group Limited Ordinary Shares",
issuer_code: "ABA",
issuer_short_name: "ABANOHEALTH",
issuer_name: "Abano Healthcare Group Limited"
}
},

{

stock:
{

code: "ACY",
exchange: "NZX",
name: "Acurity Health Group Limited Ordinary Shares",
issuer_code: "ACY",
issuer_short_name: "WAKEFIELD",
issuer_name: "Acurity Health Group Limited"
}
},

{.....etc




I am unable to load the individual stock items via my proxy which is configured like so :



Ext.define('forbar.view.Quote', {
extend: 'Ext.navigation.View',
xtype: 'quoteview',
config: {
title: 'Quotes',
items: {
xtype: 'list',
itemTpl: '<div> <h3>Code: {code}</h3> </div>',
store: {
autoLoad: true,
fields: ['stock.code'],
proxy: {
type: 'jsonp',
url: 'http://endpoint/url',
reader: {
type: 'json',
rootProperty: 'matches.matched_items'
}
}
}
}
}
});



I am unable to access the individual stock item properties? How can I map this data correctly?

mitchellsimoens
29 Aug 2012, 6:30 AM
try adding the record config to the reader:


record : 'stock'

and now your fields should map to that object