MD Sayem Ahmed
MD Sayem Ahmed

Reputation: 29176

Sencha touch reset store start param

I have a store which is attached to a List. The list also uses the ListPaging plugin to enable pagination. After I call the load method (or event) of the store, the store loads the data into the list, sending requests to the following url -

http://localhost/mysite/nodelist.php?_dc=1359309895493
    &tids=1%2C4%2C2%2C5%2C67&page=1&start=0&limit=10

After scrolling down the list and pressing the Load More... (which is appended to the list by the plugin), the store sends another request to the same url but with different parameters, enabling pagination -

http://localhost/mysite/nodelist.php?_dc=1359310357419
    &tids=1%2C4%2C2%2C5%2C67&page=2&start=10&limit=10 

Now I want to reset the value of the start and page parameter of the store. I tried to reset it by using the setExtraParam method on the proxy, but if I do that, then the control doesn't maintain the pagination - meaning that it doesn't automatically changes the page and start parameters when I press Load More....

So How do I do it?

Here is the sample code for my store -

Ext.define('MyApp.store.MyStore', {
    extend: 'Ext.data.Store',
    requires: [
        'Ext.data.reader.Json',
        'Ext.data.proxy.Ajax'
    ],

    config: {
        autoLoad: false,
        model: 'MyApp.model.MyModel',
        serverUrl: null,
        pageSize: 2,
        proxy: {
            type: 'ajax',
            actionMethods: {
                read: 'GET'
            },
            url: null,
            reader: {
                type: 'json'
            }
        },
        listeners: {
            beforeload: function () {
                console.log('Before load');
            },
            load: function (store) {
                // console.log('load');
            }
        }
    }
});

and this is the list view -

list = {
    xtype: 'list',
    cls: 'myList',
    flex: 12,
    itemTpl: '{title}',
    store: 'MyStore',
    plugins: [
        {
            xclass: 'Ext.plugin.ListPaging',
            autoPaging: false
        }
    ],
    listeners: {
        select: {
            scope: this,
            fn: this.onSelect
        },
        swipe: {
            scope: this,
            element: 'element',
            fn: this.onListSwipe
        }
    }
};

Upvotes: 0

Views: 2717

Answers (1)

rdougan
rdougan

Reputation: 7225

From looking at the source, perhaps you are looking for the currentPage config of the store?

When you load more recording using the ListPaging plugin, all it does is call nextPage in store which then calls loadPage using the currentPage config. If you reset the currentPage config back to 1 on your store, it will just assume the start is back to 0 and the page of course is 1.

Upvotes: 7

Related Questions