Hi All,
I am trying to make it more restful by dynamically setting proxy url. This is my store code:
Code:
buffered: true,
leadingBufferZone: 4,
pageSize: 2,
proxy: {
setGroupId: function(id) {this.url = '../rest/admin/group/' + id + '/user'},
type: 'ajax',
url: '../rest/admin/group/0/user',
reader: {
type: 'json',
root: 'user',
totalProperty: 'total',
successProperty: 'success'
},
},
remoteSort: true,
simpleSortMode: true,
sorters: [{
property: 'name',
direction: 'ASC'
}],
autoLoad: false,
groupId:0,
load4Group: function(id) {
if (id != this.groupId) {
this.removeAll(true),
this.groupId = id;
this.proxy.setGroupId(id);
this.pageMap.clear();
this.load({
scope: this,
callback: function(records, operation, success) {
console.log(records);
}
});
}
}
First time when calling load4Group(), it works fine. The value of "total" is 2 and it sends only one request to the server for page 1. However, afterward it will send 3 requests to the server to get pages 1, 2 and 3 even though the "total" value is 2 in these responses. The loading mask will never go way. I try to use removeAll and pageMap.clear to rest the buffer, but it does not help. If I set "buffered: false", the problem will NOT occur.
Any suggestion will be appreciated.
Thanks,
-ZJ