网格extjs中的分页

问题描述 投票:0回答:1

我想使用分页工具栏,但有一个问题。我不提供服务,所以我需要使用我拥有的 json。问题是 json 的格式与教程不同。

{
"Weather": [{
    "totalCount": 2962,
    some data
           },{
    "totalCount": 2962,
    some data
           }]
}

但在教程中我看到它应该是

{
"totalCount": 2962,
"Weather": [{
    some data
           },{
    some data
           }]
}

有什么方法可以使用我拥有的格式吗?我尝试这样做:

proxy: {
      type: 'ajax',
  url: detailURL,
       reader: {
            type: 'json',
            root: 'Weather',
            totalProperty: 'Weather.totalCount'
     }
   },

那没有用。有建议吗?

extjs pagination grid
1个回答
1
投票

您的格式错误,因为总数位于每个数组元素内部。不幸的是,您将需要更改格式。你可以尝试这样的事情:

// inside your reader (gets the totalCount of the first array element)
totalProperty: 'Weather[0].totalCount'

但这确实不是正确的选择,因为让每个数组元素具有相同的计数是没有意义的,你不同意吗?

© www.soinside.com 2019 - 2024. All rights reserved.