Return to first page of Extjs 4 grid

7.4k views Asked by At

I developed Extjs 4 grid with paging. In some event I need to refresh the grid and to return to first page.

So far I manage to refresh data but I cannot manage to put to the first page :

function RefreshData() {
    var data = globalStore;
    var store = grid.getStore();
    store.load({ params: { start: 0, limit: itemsPerPage} });
    var proxy = store.getProxy();
    proxy.url = "";
    proxy.url = getDataWithPageURL;
    grid.getStore().load();

}

As you see above,

store.load({ params: { start: 0, limit: itemsPerPage} });

In the line above I try to put to the first row but it's not working?

2

There are 2 answers

0
Gregory Nozik On BEST ANSWER

I found how to do it . I need to use loadPage function

Below is fixed function

function RefreshData() {
    var store = grid.getStore();
    store.loadPage(1); 
}
1
ChrisLo On

The initial approach should work also, but little modified:

store.load({
    page: 1,
    start: 0
});

I had a look in the source code of Ext.data.Store, method load where you can see, that page and are overwritten with current values if they are not set in the options.

Unfortunately it does not update the paging toolbar correctly.