【问题标题】:store totalLength extjs存储 totalLength extjs
【发布时间】:2011-11-19 15:34:41
【问题描述】:

我有一个这样的商店:

var store = new Ext.data.Store({
    id: 'store',
    url: 'user-list',
    remoteSort: true,
    reader: new Ext.data.JsonReader({
        root: 'data',
        totalProperty: 'result',
        id: 'id'
    }, [....])
});
store.load({
    params: {
        start: 0,
        limit: myPageSize
    }
});

如何从我的数组中访问 totalLength。 我使用了以下语句,但它们没有用:

console.log(store.totalLength)

console.log(this.store.totalLength)

console.log(store.getTotalCount())

console.log(this.store.getTotalCount())

它们返回“未定义”结果。

我的服务器 JSON 结果是这样的:

success:true

result:26

data:[Object]

【问题讨论】:

    标签: extjs extjs4 store extjs3


    【解决方案1】:

    您应该在代理属性中提及 URL。

    var store = new Ext.data.Store({
          id:'store',  
          proxy: new Ext.data.HttpProxy({
            url: 'user-list'
        }),
          remoteSort: true,
          reader: new Ext.data.JsonReader(
              {
                root:'data',
                totalProperty: 'result',
                id:'id'
              }, [
                ....
              ]
          )
        });
    
    
    store.load({
            params: {
                start: 0,          
                limit: myPageSize
            }
        });
    

    那就试试store.getCount(),这个方法很好用,这个没问题。

    【讨论】:

      【解决方案2】:

      在 ExtJS 3 和 4 中都可以使用

      store.getCount()

      返回存储中的记录数

      【讨论】:

      • 所以它正在工作,它正在返回一个值......而在您返回“未定义”的其他方法之前。您的代码一定有问题导致记录无法加载
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-08
      • 1970-01-01
      • 1970-01-01
      • 2012-09-19
      • 2011-02-18
      • 2012-05-19
      • 2013-03-31
      相关资源
      最近更新 更多