【问题标题】:ExtJS 4 store and manage recordExtJS 4 存储和管理记录
【发布时间】:2013-04-27 01:47:13
【问题描述】:

我有一个关于 extjs 4 的问题。 下面是我的storeMsg

   var storeMsg = this.getMessageStore();
            storeMsg.load({
                    scope: this,
                    autoLoad: true,
                    params:{
                        read_conditions: Ext.JSON.encode({
                            "employee_rid": '7976', 
                            "year" : '2013',  //etos
                            "kind_holiday_rid" : '1',
                            "request_days" : '5'
                        })
                    },
                    callback: function(records, operation, success) {
                            // do something after the load finishes
                            console.log(records[0].get('remain'));
                            console.log(records[0].get('messages'));

                    }
            });

我接受一个像

这样的 json 响应
{"total":1,"success":true,"data":[{"status":"true","messages":"\u03a3\u03c9\u03c3\u03c4\u03cc \u03b1\u03af\u03c4\u03b7\u03bc\u03b1 \u03ac\u03b4\u03b5\u03b9\u03b1\u03c2","remain":"25"}]}

我想从 storeMsg.load() 之外的 json (ex true) 获取字段状态; 例如

var vstatus = Ext.StoreMgr.lookup(storeMsg).data.items[0].data.status

但我收到消息,此 vstatus 未定义

我更改了代码变量(vstatus): var vstatus = Ext.StoreMgr.lookup(storeMsg).getProxy().getReader(); 我正在接受和反对 className "Ext.data.reader.Json" 它有一些属性。一个属性是

 jsonData 
    data
      remain     25
      status     true
      message    "Is correct"
    total          1
    success       true

我屈服了 var vstatus = Ext.StoreMgr.lookup(storeMsg).getProxy().getReader().jsonData; 我接受了这条信息(undefined)。 你知道如何从 jsonData.data.status = true; 获取值吗? tnx

关于 store 、 proxy 和 reader 的完整代码如下

    Ext.define('MHR.store.Message',{
       extend       : 'Ext.data.Store',
           model        : 'MHR.model.Message',
           storeId      : 'Message',
           autoLoad         : true,
       proxy        : {
    type: 'ajax',
    api: {
        read    : 'php/crud.php?action=check'

    },
    actionMethods: {
       read    : 'POST',
            },
    reader: {
                type: 'json',
        root: 'data',
        rootProperty: 'data',
        successProperty: 'success',
        messageProperty: 'message'
    },
            extraParams : {
               'read_conditions': ''

           }
   }
 });

【问题讨论】:

  • 您能发布您的完整存储/代理/阅读器配置吗?这将有助于确定问题出在您的商店还是您访问记录的方式。

标签: json extjs4 store


【解决方案1】:

尝试:

storeMsg.each(function(record) {
    var status = record.get('status');
});

【讨论】:

    猜你喜欢
    • 2013-02-13
    • 2018-12-19
    • 1970-01-01
    • 2011-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    • 2013-03-31
    相关资源
    最近更新 更多