Sencha touch 2:通過代理在商店檢索信息 (Sencha touch 2: retrieve infos by proxy in store)


問題描述

Sencha touch 2:通過代理在商店檢索信息 (Sencha touch 2: retrieve infos by proxy in store)

I work for a project of mobile application and I have a problem to retrieve informations by using proxy in a store. It's an application to manage Train Stations, and for a Station, I call a WebService which retrieve the 10 next trains ( in json ).

I have 2 classes, TrainStation ( Gare in french ;) ) and Train

the method in Gare to retrieve the Trains:

getListTrains: function(TR3A) {
    console.log('plop');
    var trains = Ext.create('Ext.data.Store', {
        model: 'Train',
        proxy: {
            type: 'ajax',
            url: 'http://eclernet‑mobile.dev.dsit‑hp.sncf.fr/Trainservice.svc/GetListTrainsAtGare/'+TR3A,
            method: 'POST',
            headers: {
                'Accept': 'application/json'
            },
            reader: {
                type: 'json'
            }
        }
    });

    console.log(trains);
}

the class Train ( which extend Model to using the method ):

Ext.define('Train', {
extend: 'Ext.data.Model',
config: {   
    codeMission: null,      
    numero:  null,
    sens: null,     
    dessertes: null,    
    voie: null,
    heureProbable: null,        
    heureTheorique: null,
    voiePrecedente: null,   
    quai: null,
    retard: null
},  


constructor: function(config) {
    this.initConfig(config);    
},  

});

When I call my method with a valid train station, my console.log(trains); retrieve an empty object ...

my JSON: 

[
{
    "codeMission": "AMIE",
    "dessertes": [
        {
            "codeTR3A": "VPL",
            "nom": "Villiers St Paul"
        },
        {
            "codeTR3A": "RIA",
            "nom": "Rieux Angicourt"
        },
        {
            "codeTR3A": "PXE",
            "nom": "Pont Ste Maxence"
        },
        {
            "codeTR3A": "CVE",
            "nom": "Chevrieres"
        },
        {
            "codeTR3A": "LUE",
            "nom": "Longueil Ste Marie"
        },
        {
            "codeTR3A": "LXS",
            "nom": "Le Meux La Croix"
        },
        {
            "codeTR3A": "CPE",
            "nom": "Compiegne"
        }
    ],
    "heureProbable": "02/08/2012 15:21",
    "heureTheorique": "02/08/2012 15:21",
    "numero": "847809",
    "quai": null,
    "retard": null,
    "sens": "I",
    "voie": "1",
    "voiePrecedente": null
},
{
    "codeMission": "PADI",
    "dessertes": [
        {
            "codeTR3A": "CLY",
            "nom": "Chantilly Gouvieux"
        },
        {
            "codeTR3A": "ORY",
            "nom": "Orry la Ville"
        },
        {
            "codeTR3A": "PNO",
            "nom": "Paris Nord GL"
        }
    ],
    "heureProbable": "02/08/2012 15:39",
    "heureTheorique": "02/08/2012 15:39",
    "numero": "847616",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "DE",
    "voiePrecedente": null
},
{
    "codeMission": "TOLI",
    "dessertes": [
        {
            "codeTR3A": "SLT",
            "nom": "St Leu d'Esserent"
        },
        {
            "codeTR3A": "PYO",
            "nom": "Précy sur Oise"
        },
        {
            "codeTR3A": "BRN",
            "nom": "Boran sur Oise"
        },
        {
            "codeTR3A": "BRK",
            "nom": "Bruyères sur Oise"
        },
        {
            "codeTR3A": "PEB",
            "nom": "Persan Beaumont"
        },
        {
            "codeTR3A": "CPO",
            "nom": "Champagne sur Oise"
        },
        {
            "codeTR3A": "IAP",
            "nom": "L'Isle Adam Parmain"
        },
        {
            "codeTR3A": "VMD",
            "nom": "Valmondois"
        },
        {
            "codeTR3A": "AUW",
            "nom": "Auvers sur Oise"
        },
        {
            "codeTR3A": "CPW",
            "nom": "Chaponval"
        },
        {
            "codeTR3A": "PPT",
            "nom": "Pont Petit"
        },
        {
            "codeTR3A": "EPL",
            "nom": "Epluches"
        },
        {
            "codeTR3A": "SOA",
            "nom": "St Ouen l'Aumone"
        },
        {
            "codeTR3A": "PSE",
            "nom": "Pontoise"
        }
    ],
    "heureProbable": "02/08/2012 15:54",
    "heureTheorique": "02/08/2012 15:54",
    "numero": "121038",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "DE",
    "voiePrecedente": null
},
{
    "codeMission": "ZUCO",
    "dessertes": [
        {
            "codeTR3A": "CLY",
            "nom": "Chantilly Gouvieux"
        },
        {
            "codeTR3A": "ORY",
            "nom": "Orry la Ville"
        },
        {
            "codeTR3A": "BBN",
            "nom": "La Borne Blanche"
        },
        {
            "codeTR3A": "SUR",
            "nom": "Survilliers Fosses"
        },
        {
            "codeTR3A": "LOV",
            "nom": "Louvres"
        },
        {
            "codeTR3A": "LNX",
            "nom": "Les Noues"
        },
        {
            "codeTR3A": "GOU",
            "nom": "Goussainville"
        },
        {
            "codeTR3A": "VIB",
            "nom": "Villiers le Bel"
        },
        {
            "codeTR3A": "GAJ",
            "nom": "Garges Sarcelles"
        },
        {
            "codeTR3A": "PRF",
            "nom": "Pierrefitte Stains"
        },
        {
            "codeTR3A": "SDE",
            "nom": "St Denis"
        },
        {
            "codeTR3A": "SFD",
            "nom": "Stade de France St D"
        },
        {
            "codeTR3A": "GDS",
            "nom": "Paris Nord RER"
        },
        {
            "codeTR3A": "CLX",
            "nom": "Châtelet les Halles"
        },
        {
            "codeTR3A": "PAA",
            "nom": "Paris Lyon Banlieue"
        },
        {
            "codeTR3A": "MFA",
            "nom": "Maisons Alfort"
        },
        {
            "codeTR3A": "VSG",
            "nom": "Villeneuve S Georges"
        },
        {
            "codeTR3A": "KRW",
            "nom": "Montgeron Crosne"
        },
        {
            "codeTR3A": "YES",
            "nom": "Yerres"
        },
        {
            "codeTR3A": "BNY",
            "nom": "Brunoy"
        },
        {
            "codeTR3A": "BXI",
            "nom": "Boussy St Antoine"
        },
        {
            "codeTR3A": "CBV",
            "nom": "Combs la Ville"
        },
        {
            "codeTR3A": "LIU",
            "nom": "Lieusaint Moissy"
        },
        {
            "codeTR3A": "ZTN",
            "nom": "Savigny le Temple"
        },
        {
            "codeTR3A": "CES",
            "nom": "Cesson"
        },
        {
            "codeTR3A": "WEE",
            "nom": "Le Mée"
        },
        {
            "codeTR3A": "MEL",
            "nom": "Melun"
        }
    ],
    "heureProbable": "02/08/2012 15:59",
    "heureTheorique": "02/08/2012 15:59",
    "numero": "153260",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "DE",
    "voiePrecedente": null
},
{
    "codeMission": "PADI",
    "dessertes": [
        {
            "codeTR3A": "PNO",
            "nom": "Paris Nord GL"
        }
    ],
    "heureProbable": "02/08/2012 16:07",
    "heureTheorique": "02/08/2012 16:07",
    "numero": "848522",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "2",
    "voiePrecedente": null
},
{
    "codeMission": "AMIE",
    "dessertes": [
        {
            "codeTR3A": "PXE",
            "nom": "Pont Ste Maxence"
        },
        {
            "codeTR3A": "CPE",
            "nom": "Compiegne"
        },
        {
            "codeTR3A": "NOY",
            "nom": "Noyon"
        },
        {
            "codeTR3A": "CNY",
            "nom": "Chauny"
        },
        {
            "codeTR3A": "TGR",
            "nom": "Tergnier"
        },
        {
            "codeTR3A": "SQ",
            "nom": "St Quentin"
        }
    ],
    "heureProbable": "02/08/2012 16:35",
    "heureTheorique": "02/08/2012 16:35",
    "numero": "847907",
    "quai": null,
    "retard": null,
    "sens": "I",
    "voie": "1",
    "voiePrecedente": null
},
{
    "codeMission": "PADI",
    "dessertes": [
        {
            "codeTR3A": "CLY",
            "nom": "Chantilly Gouvieux"
        },
        {
            "codeTR3A": "ORY",
            "nom": "Orry la Ville"
        },
        {
            "codeTR3A": "PNO",
            "nom": "Paris Nord GL"
        }
    ],
    "heureProbable": "02/08/2012 16:40",
    "heureTheorique": "02/08/2012 16:40",
    "numero": "847822",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "2",
    "voiePrecedente": null
},
{
    "codeMission": "AMIE",
    "dessertes": [
        {
            "codeTR3A": "LAI",
            "nom": "Laigneville"
        },
        {
            "codeTR3A": "LIA",
            "nom": "Liancourt Rantigny"
        },
        {
            "codeTR3A": "CDO",
            "nom": "Clermont de l'Oise"
        },
        {
            "codeTR3A": "AVY",
            "nom": "Avréchy"
        },
        {
            "codeTR3A": "SJS",
            "nom": "St Just en Chaussée"
        }
    ],
    "heureProbable": "02/08/2012 16:43",
    "heureTheorique": "02/08/2012 16:43",
    "numero": "848517",
    "quai": null,
    "retard": null,
    "sens": "I",
    "voie": "1",
    "voiePrecedente": null
},
{
    "codeMission": "TOLI",
    "dessertes": [
        {
            "codeTR3A": "SLT",
            "nom": "St Leu d'Esserent"
        },
        {
            "codeTR3A": "PYO",
            "nom": "Précy sur Oise"
        },
        {
            "codeTR3A": "BRN",
            "nom": "Boran sur Oise"
        },
        {
            "codeTR3A": "BRK",
            "nom": "Bruyères sur Oise"
        },
        {
            "codeTR3A": "PEB",
            "nom": "Persan Beaumont"
        },
        {
            "codeTR3A": "CPO",
            "nom": "Champagne sur Oise"
        },
        {
            "codeTR3A": "IAP",
            "nom": "L'Isle Adam Parmain"
        },
        {
            "codeTR3A": "VMD",
            "nom": "Valmondois"
        },
        {
            "codeTR3A": "AUW",
            "nom": "Auvers sur Oise"
        },
        {
            "codeTR3A": "CPW",
            "nom": "Chaponval"
        },
        {
            "codeTR3A": "PPT",
            "nom": "Pont Petit"
        },
        {
            "codeTR3A": "EPL",
            "nom": "Epluches"
        },
        {
            "codeTR3A": "SOA",
            "nom": "St Ouen l'Aumone"
        },
        {
            "codeTR3A": "PSE",
            "nom": "Pontoise"
        }
    ],
    "heureProbable": "02/08/2012 16:54",
    "heureTheorique": "02/08/2012 16:54",
    "numero": "121042",
    "quai": null,
    "retard": null,
    "sens": "P",
    "voie": "DE",
    "voiePrecedente": null
},
{
    "codeMission": "TSOL",
    "dessertes": [],
    "heureProbable": "02/08/2012 17:07",
    "heureTheorique": "02/08/2012 17:07",
    "numero": "121031",
    "quai": null,
    "retard": null,
    "sens": "I",
    "voie": "AE",
    "voiePrecedente": null
}

]

What the problem?

‑‑‑‑‑

參考解法

方法 1:

May be 

        reader: {
            type: 'json',
            model: 'Train'
        }

??

(by Craysisolegtaranenko)

參考文件

  1. Sencha touch 2: retrieve infos by proxy in store (CC BY‑SA 3.0/4.0)

#store #sencha-touch-2 #JSON #extjs #proxy






相關問題

Sencha touch 2:通過代理在商店檢索信息 (Sencha touch 2: retrieve infos by proxy in store)

Đại diện cửa hàng ExtJS Costum (ExtJS Costum store representation)

Cửa hàng Sencha Touch 2 đạt kỷ lục (Sencha Touch 2 store get record)

更換和存放 (Replacing and Storing)

如何重命名Window Store App的.exe(可執行文件)文件? (How to rename .exe (executable) file of Window Store App?)

Socket.io 和 Extjs:為 Store 檢索數據 (Socket.io and Extjs: Retrieving data for Store)

獲取組件中的輸入值反應本機 (Get a value of input in a component react native)

為小組存儲生產密碼的最佳實踐 (Best practices for storing production passwords for small groups)

有人可以解釋一下 iphone 證書的東西,步驟是什麼樣的嗎? (Can someone explain me the iphone certificate stuff, how the steps look like?)

用戶退出應用程序時在 MapKit 中存儲註釋 (Store annotations in MapKit when user quit application)

使用 Injector angular 7 將 Store 注入子類 (Injecting Store to sub classes using Injector angular 7)

通過 VBA 中的輸入創建數組 (Creath an array by input in VBA)







留言討論