【问题标题】:why my jsonStore doesn't have any data?为什么我的 jsonStore 没有任何数据?
【发布时间】:2012-05-20 15:53:56
【问题描述】:

我有一个这样的 jsonStore

var ch01_store = new Ext.data.JsonStore({
        autoLoad:true,

        storeId: 'ch01_store',
        proxy: new Ext.data.HttpProxy({
            url: 'index.php/test/get_ch01/10',
            method: 'POST'
        }),
        root: 'data',
        totalProperty: 'results',
        remoteSort: true,
        fields: [
            {name: 'date_time', mapping: 'date_time'},
            {name: 'chart_data', mapping: 'chart_data'}
        ]
    });

并且“localhost/myweb/index.php/test/get_ch01/10” url 在页面上产生了这个

   {
   "success": true,
   "results": 10,
   "data": [{
         "date_time": "5/12/2012 13:13:33",
         "chart_data": "3.5"
      },
      {
         "date_time": "5/12/2012 13:13:34",
         "chart_data": "0.0"
      },
      {
         "date_time": "5/12/2012 13:13:35",
         "chart_data": "3.5"
      },
      {
         "date_time": "5/12/2012 13:13:36",
         "chart_data": "0.0"
      },
      {
         "date_time": "5/12/2012 13:13:4",
         "chart_data": "0.0"
      },
      {
         "date_time": "5/12/2012 13:13:5",
         "chart_data": "3.5"
      },
      {
         "date_time": "5/12/2012 13:13:6",
         "chart_data": "0.0"
      },
      {
         "date_time": "5/12/2012 13:13:7",
         "chart_data": "3.5"
      },
      {
         "date_time": "5/12/2012 13:13:8",
         "chart_data": "0.0"
      },
      {
         "date_time": "5/12/2012 13:13:9",
         "chart_data": "3.5"
      }
   ]
}

但是当我执行时

console.log(ch01_store.getCount()); 

日志显示为零 我正在尝试在 gridPanel 上填充它,结果仍然是空的,有人可以帮帮我吗?

【问题讨论】:

  • 1.您是否在控制台中看到如何请求和检索数据? 2.尝试添加sucessProperty: 'success'但这应该是默认值
  • @sha : 我在 JsonStore 文档中没有看到 successProperty 配置,我尝试了任何方式,但仍然无法正常工作
  • 您在网络流量中看到存储数据是如何检索的吗?

标签: extjs4 jsonstore


【解决方案1】:

像这样设置代理并尝试:

proxy: {
    type: 'ajax',
    reader: {
        type: 'json',
        root: 'xxxxxx'
        }
}

【讨论】:

    猜你喜欢
    • 2021-07-23
    • 2019-08-13
    • 2016-07-19
    • 1970-01-01
    • 1970-01-01
    • 2020-02-29
    • 1970-01-01
    • 2019-07-20
    • 1970-01-01
    相关资源
    最近更新 更多