Hybrid View

  1. #1
    Sencha User
    Join Date
    Dec 2008
    Posts
    8
    Vote Rating
    0
    zjda is on a distinguished road

      0  

    Default Store locding problem with buffered: true,

    Store locding problem with buffered: true,


    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

  2. #2
    Sencha User
    Join Date
    Dec 2008
    Posts
    8
    Vote Rating
    0
    zjda is on a distinguished road

      0  

    Default


    The following code fixes the problem:

    Code:
        load4Group: function(id) {
            if (id != this.groupId) {
                this.groupId = id;
                this.proxy.setGroupId(id);
                this.removeAll();
                if (this.prefetchData) {
                    this.prefetchData.clear(); 
                    delete this.guaranteedStart;
                    delete this.guaranteedEnd;
                    delete this.totalCount;
                }
                this.guaranteeRange(0, this.pageSize - 1); 
            }
        }
    Thanks,
    -ZJ