【问题标题】:Get property of local store javascript file in sencha touch在sencha touch中获取本地商店javascript文件的属性
【发布时间】:2013-07-14 22:51:06
【问题描述】:

我想从我的 users.json 中获取成功属性。我怎样才能访问它?此代码来自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"
        }
    ]
}

代码:

// 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})"
});

【问题讨论】:

  • 你有什么错误吗?
  • 不,这是有效的。但是我怎样才能访问成功属性呢?我试图在我商店的 Object 中找到它,但找不到任何东西。
  • 你为什么不在代理阅读器中设置successProperty?如果您想使用成功处理异常..那么我认为您需要查看以下链接 [link1] (sencha.com/forum/…) [link2] (sencha.com/forum/…) [link3] (sencha.com/forum/…)

标签: javascript html sencha-touch store


【解决方案1】:

您可以通过

获得成功属性
var success = myStore._proxy._reader.rawData.success;

【讨论】:

    猜你喜欢
    • 2014-01-25
    • 2012-05-29
    • 1970-01-01
    • 2013-03-19
    • 1970-01-01
    • 2012-06-17
    • 1970-01-01
    • 2011-09-01
    • 2014-03-03
    相关资源
    最近更新 更多