mercredi 28 mai 2014

Is this JSON JSONPStore is able to read somehow ?

I've got the JSON below:

Code:



[
[
{
"Key": "mobilephone",
"Value": "(430) 565-1212"
},
{
"Key": "firstname",
"Value": "John"
}
],
[
{
"Key": "mobilephone",
"Value": "(430) 565-1313"
},
{
"Key": "firstname",
"Value": "Mark"
}
]
]

JSONLint says it's all good. But I don't really have any top element like "allElements" or anything.

FWIW, the JSON comes from an ASP MVC WebAPI web service and I can change it if need be. (It's a List<AttributeCollection>. AttributeCollection is also somewhat of a list as you can see).


I'm trying to load it into this and I'm getting the "Loading..." spinning logo for 30 seconds before it stops and no data is shown, so I'm pretty sure it's my 'root' property or my JSON format that's the issue.



Code:



Ext.define('Contact', {
extend: 'Ext.data.Model',
fields: [
{ name: 'firstname', type: 'string', mapping: 'Value'},
{ name: 'lastname', type: 'string', mapping: 'Value'},
{ name: 'contactid', type: 'string', mapping: 'Value'}
]


});


var contactStore = new Ext.data.JsonPStore({
storeId: 'contactStore',
id: 'contactid',
proxy: { type: 'jsonp', url: 'http://webserver/CustomerPortal.WebAPI/api/contact/get', headers: { 'Content-type': 'application/json'} },
autoLoad: true,
//root: '', //That's a bit hard to decide as I have no top element...
model: 'Contact'
});

Thanks!


Aucun commentaire:

Enregistrer un commentaire