18

i need to reset paging toolbar parameters as "page", "start", "limit" when i click on a search button to re-load grid store with different parametres!

how can i do it?

the problem is that when i am on the next page, and i do a new search, i have the parameters page=2, start=25, limit=25 dirty, instead i need to reset this parametres.

my code:

listeners: {
    click: function(){
        Ext.getCmp('GrlGio').getStore().removeAll();
        Ext.getCmp('GrlGio').store.load({
                params:{
                  mode: "RIC",
                  DataRicerca: dd,
                  Pit: Ext.getCmp('cmbPiattaforma').getValue()
                }
        });
    }
 }

thanks!

Joy
  • 406
  • 4
  • 18
jack.cap.rooney
  • 1,306
  • 3
  • 21
  • 37

11 Answers11

17

In Ext 4, I found loadPage() worked pretty well for resetting the data store and making the paging toolbar go back to the first page. Example:

store.loadPage(1) // note: 1-based, not 0-based
XåpplI'-I0llwlg'I -
  • 21,649
  • 28
  • 102
  • 151
8

Guys currentPage=1 did the trick for me

before loading the store every time call the below By the way i am getting 500 results and loading in cache Pagination is for local, any way you can try this before any new search

                        var store = Ext.getStore('MyStoreS');
                        store.proxy.extraParams = { employeeId : searchStr};

                        store.currentPage = 1;

                        store.load();
7

you can manualy reset the params

Ext.getCmp('GrlGio').getStore().getProxy().pageParam =1;
Ext.getCmp('GrlGio').getStore().getProxy().startParam =0;

and then do the store load. I know it looks hardcoded but it's the only solution i found...

nscrob
  • 4,483
  • 1
  • 20
  • 24
  • 1
    thanks! this is good for me! but HOW CAN I REFRESH pagingtollbar info?? – jack.cap.rooney Sep 15 '11 at 15:52
  • with pagingToolbar.moveFirst() i do another request! so in this way, when i click on serarch button, i get 2 once the same store from server – jack.cap.rooney Sep 15 '11 at 16:01
  • .. maybe you can use suspend events for the paging toolbar , to disable the load from the moveFirst function .. i hope this helps .. i haven't tried it – nscrob Sep 15 '11 at 16:06
  • i try with suspendEvents: true, and pagingToolbar.moveFirst() but i see in firebug two rwwquest on server! – jack.cap.rooney Sep 15 '11 at 16:13
  • I've looked in the code of the pagingtoolbar and it recalculates the paging data on the store load, it could be just a problem of refreshing the view. Maybe you can set a breakpoint in ext-all-debug.js (if you are using this one, otherwise you can change it to this one) in the onLoad private function of the paging toolbar class and see what page data is set for the toolbar – nscrob Sep 16 '11 at 11:33
  • thanks for your answer! do you have same example?? becouse i try with ext.getCmp(id-pagetoolbar).doLayout() but this not good! – jack.cap.rooney Sep 19 '11 at 08:25
  • i solve it with Ext.getCmp('GrlGio').getStore().getProxy().pageParam = "1"; becouse i see documentation that pageParam need a string! than k a lots for your help – jack.cap.rooney Sep 19 '11 at 09:44
  • 1
    It seems that pageParam is the NAME of the page param. By default it is "page". That's why you need to specify a string. The answer here below is the correct one: store.currentPage = 1. – Lawrence Jan 15 '15 at 17:01
6

Try this -

pagingToolbar.moveFirst();
Amol Katdare
  • 6,740
  • 2
  • 33
  • 36
  • it's not good for me becouse i see that send two request on server! first request is store.load() and second request is with new parametres! how can i solve it? – jack.cap.rooney Sep 15 '11 at 15:38
5

Define following function "resetStartParam" , by overriding ext.data.store:

Ext.override(Ext.data.Store, {

            resetStartParam:function(){

                //get the latest store options
                var storeOptions=this.lastOptions;

                if(storeOptions!=undefined){

                    //get the param names
                    var pn = this.paramNames;

                    //get the params from options
                    var params=storeOptions.params;

                    //change the param start value to zero
                    params[pn.start] = 0;

                    //reset options params with this new params
                    storeOptions.params=params;

                    //apply this new options to store options
                    this.storeOptions(storeOptions);
                    }
                }
    });

Now call this function on click of your search button:

Ext.getCmp('GrlGio').getStore().resetStartParam(); 

Thats it.It should work.

kleopatra
  • 51,061
  • 28
  • 99
  • 211
rst
  • 339
  • 5
  • 22
4

I know that this is an old post but I thought I'd add in my pennies work. I'm using EXTJS 4 and had a similar problem. When I did a new search the page number etc did not reset. The solution I found, which appears to work with the nav bar automatically is using the currentPage attribute of the store. I do have a slight odd setup but doing this.currentPage = 1 when I do a new search works fine for me

4

try this in your handler

Ext.getCmp('gridpanel').getStore().removeAll();
Ext.getCmp('PagingToolbar').moveFirst();

after this, put your search query and load the store accordingly

Ext.getCmp('gridpanel').getStore().load({params : { start : 0, limit : maxRecords, searchText : _searchText } });

hope it helps

Ankur
  • 140
  • 2
4

just call pagingToolbar.onLoad() after removeAll(). Plain and simple.

Lawrence
  • 1,035
  • 13
  • 8
3

This work fine (refresh correctly the paging info):

    myStore.removeAll();

    myStore.fireEvent('load', myStore, [], {});
piscestou
  • 31
  • 1
3

Here is how I achieved search with paging. It only does 1 request and it refreshes the paging data.

onExecuteSearch: function(){
  var params = this.getSearchForm().getForm().getFieldValues()
      , proxy = this.getSomeGrid().getStore().getProxy();

  proxy.extraParams = params;
  this.getPagingToolbar().moveFirst();
}

getFieldValues() documentation: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.form.Basic-method-getFieldValues

For more about the proxy "extraParams" look here: ExtJs4 - Store baseParams config property?

Community
  • 1
  • 1
Justin
  • 1,310
  • 3
  • 18
  • 29
  • Hey @jack - I see this question is a few months old but your currently selected answer did not help me. I have solved some problems you were having with the duplicate request and the paging information not updating. Hope this helps someone. – Justin Feb 06 '12 at 20:43
  • It helped me! Just use the `moveFirst()` in staid of the `load()` function... no need for manually resetting parameters. Thanx! – VDP Sep 17 '12 at 07:34
2

Had to change the page size to 500 for printing the WHOLE store/grid, and once printed, restore the grid to the original page size of 25.

    // 500 records are now in the store and on the grid
    ux.core.grid.Printer.print(this.getOrderList());
    store.pageSize = this.displaySize;   // new page size is 25
    this.getPagingToolbar().doRefresh(); // equivalent of pressing a refresh button on the toolbar

does the trick - reloads store with the same sorters/filters/currentPage

Yuri Gridin
  • 469
  • 5
  • 6