【问题标题】:ExtJS: JsonStore is not loading at allExtJS:JsonStore 根本没有加载
【发布时间】:2012-05-28 04:12:59
【问题描述】:

我有一个 jsonstore:

jstore = new Ext.data.JsonStore({
    fields: ['id', 'timer', 'name', 'message'],
    root: 'data',
    autoLoad: true,
    proxy: new Ext.data.HttpProxy({
                    url: 'chat.php',
                    method: 'GET',
            }),
            remoteSort: false
});

它没有从 url 加载数据。 我的 php 文件可以正常工作,如果我输入的 url 与商店使用的 url 相同,输出是这样的:

{fields: ['id', 'name', 'time', 'message'], 'data': [{id: '5', name: 'stefano', time: '2012-05-21 14:08:58', message: 'mymessage'}]}

这应该是一个正确的 json 字符串,不是吗?

商店既没有通过自动加载也没有通过显式调用来加载

jstore.load({params: {mode:'RetrieveNew', id:'-1'}});

有什么可能导致这种情况的想法吗?非常感谢!

【问题讨论】:

    标签: json extjs store


    【解决方案1】:

    只是添加我的解决方案:

    var stateStore = new Ext.data.JsonStore({
        autoLoad: true,
        root: 'states',
        proxy: new Ext.data.HttpProxy({
            url: 'js/query/states.json',
            method: 'GET'
        }),
        fields: ['stateCode', 'stateName'],
    });
    
    stateStore.load();
    

    还有我的 states.json

    {
      "states": [
          { "stateCode": "01", "stateName": "Johor" },
          { "stateCode": "02", "stateName": "Kedah" },
          { "stateCode": "10", "stateName": "Selangor" }
      ]      
    }
    

    希望它能帮助其他人;)

    【讨论】:

      【解决方案2】:

      我在加载商店时遇到了同样的问题。

      为了修复它,我用 Ext.data.Store 替换了 Ext.data.JsonStore。其他参数相同。 所以这是我的自动加载 ExtJS 商店的例子:

      this.datesStore = new Ext.data.Store({
                              id: 'datestore',
                              root: 'dates',
                              autoLoad: true,
                              proxy: new Ext.data.HttpProxy({
                                          url: '/url/to/the/data',
                                          method: 'GET'
                                      }),
                              fields: ['date']
                          });
      

      【讨论】:

        【解决方案3】:

        你打错了:autoLoad 不是autoload

        【讨论】:

        • 是的,谢谢..已修复,遗憾的是这似乎对问题没有影响,firebug 控制台仍然无声,客户端和服务器端之间没有任何通信迹象。
        • 你不需要专门配置你正在使用的模型吗?
        • 不就是在store中指定字段和root来完成的吗?对不起,我对 extjs 的这个功能有点陌生..
        • +1,正确。问题与添加autoLoad并设置为true有关。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-05
        • 1970-01-01
        • 1970-01-01
        • 2018-12-29
        • 2020-09-26
        相关资源
        最近更新 更多