在网格extjs中进行分页

时间:2012-07-18 14:35:19

标签: extjs grid paging

我想使用分页工具栏但有一个问题。我没有提供服务所以我需要与我有的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'
     }
   },

没有奏效。建议?

1 个答案:

答案 0 :(得分:1)

您的格式错误,因为总计数在每个数组元素内部。不幸的是,您需要更改格式。您可以尝试以下方式:

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

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

相关问题