Domanda

Utilizzando Sencha Touch 2, sto cercando di rendere un nestedlist con delega JSON. L'aspetto JSON come

[
  {
    "start": "0"
  },
  {
    "format": "json"
  },
  .......
  {
    "GetFolderListing": [
        {
            "folder": {
                "total": 0,
                "id": "Calendar",
                "name": "Calendar",
                "unread": 0,
            }
        },
        {
            "folder": {
                "total": 0,
                "id": "Contacts",
                "name": "Contacts",
                "unread": 0,
            }
        },
  .......

Voglio usare GetFolderListing.folder.name come displayField Il mio negozio assomiglia

Ext.define('foo.store.FolderListing', {
extend: 'Ext.data.TreeStore',
require: ['foo.model.FolderListing'],
config: {
    model: 'foo.model.FolderListing',
    recursive: true,
    proxy: {
    type: 'jsonp',
    url: 'http://localhost/?xx=yy&format=json',
    callbackKey: "jsoncallback",
    reader: {
        type: 'json',
        rootProperty: 'GetFolderListing',
        record: 'folder'
    }
}
 }
});

In questo momento tutto quello che ottiene è un errore TypeError Uncaught: Impossibile leggere la proprietà 'id' di non definito

Qualcuno potrebbe fornire indicazioni su come risolvere questo o di debug meglio o come fare il parsing personalizzato e passare articoli di nuovo un negozio?

Grazie

======== Aggiornamento - affinché il rootProperty di lavoro nel lettore, il json doveva essere un JsonObject piuttosto che con un array json esempio

{
"GetFolderListing": [
    {
        "folder": {
            "total": 0,
            "id": "Contacts",
            "name": "Contacts",
            "unread": 0,
            "leaf": "true"
        }
    },
    {
        "folder": {
            "total": 0,
            "id": "Conversation Action Settings",
            "name": "Conversation Action Settings",
            "unread": 0,
            "leaf": "true"
        }
    },
    .......
È stato utile?

Soluzione

Il tuo aspetto JSON come un array. I mezzi dei messaggi di errore che il codice tenta di accedere a una proprietà di una variabile indefinita o proprietà.

La mia prima ipotesi è che il lettore non è configurato correttamente per il formato tipo array JSON.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top