简体   繁体   中英

Get property of local store javascript file in sencha touch

I want to get the success property from my users.json. How can I access it? This code is from here .

{
    "success": true,
    "users": [
        {
            "firstName": "Tommy",
            "lastName": "Maintz",
            "age": 24,
            "eyeColor": "green"
        },
        {
            "firstName": "Aaron",
            "lastName": "Conran",
            "age": 26,
            "eyeColor": "blue"
        },
        {
            "firstName": "Jamie",
            "lastName": "Avins",
            "age": 37,
            "eyeColor": "brown"
        }
    ]
}

Code:

// Set up a model to use in our Store
Ext.define("User", {
    extend: "Ext.data.Model",
    config: {
        fields: [
            {name: "firstName", type: "string"},
            {name: "lastName",  type: "string"},
            {name: "age",       type: "int"},
            {name: "eyeColor",  type: "string"}
        ]
    }
});

var myStore = Ext.create("Ext.data.Store", {
    model: "User",
    proxy: {
        type: "ajax",
        url : "/users.json",
        reader: {
            type: "json",
            rootProperty: "users"
        }
    },
    autoLoad: true
});

Ext.create("Ext.List", {
    fullscreen: true,
    store: myStore,
    itemTpl: "{lastName}, {firstName} ({age})"
});

您可以使用获得成功属性

var success = myStore._proxy._reader.rawData.success;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM