0
votes

I have a store like this:

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
    }
});

how can I access totalLength off my array. i used this following statement but they didn't worked :

console.log(store.totalLength)

console.log(this.store.totalLength)

console.log(store.getTotalCount())

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

they are return 'undefined' result.

My server JSON result is like this:

success:true

result:26

data:[Object]
2

2 Answers

1
votes

You should mention URL inside proxy attribute.

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
        }
    });

Then try store.getCount(), this method works fine there is no problem with this.

1
votes

In both ExtJS 3 and 4 you can use

store.getCount()

to return the number of records in the store