0
votes

I have a gridpanel and i create store in initComponet function like

,initComponent: function() {
        var store = Ext.create('Ext.data.Store', {
            model: 'MyObject',
            autoLoad: false,
            pageSize:22,
            remoteSort:true,
            proxy: {
                 type: 'ajax',
                 url: 'example.php',
                 reader: {
                    type: 'json',
                    totalProperty: 'total',
                    root: 'results'   
                 }
             }
        });
        this.store = store;
        this.dockedItems = [{
           xtype: 'pagingtoolbar',
           store: this.store,
           displayMsg: '{0} - {1} / {2}',
           emptyMsg: 'empty',
           dock: 'bottom',
           displayInfo: true,
           pageSize: 22
        }];

        this.callParent(arguments);
        this.store.load({params:{start:0, limit:22}});
    }

I make a form search with some value and when i press search button i will do below code

grid.store.load({
       params:{
             start:0, 
             limit:22, 
             signalSearch: 1,
             search1: myValue1,
             search2: myValue2,
       }
});

In my php file will catch that to know that's search

if ( have $_REQUEST["signalSearch"]) {
     // print json with condition search
}else {
     // print json with all data
}

And results return with 2 page (it well). But when i press Next page button to see some results on page 2 But my store load fail (i think they call store.load({params:{start:0, limit:22}}); when i press next page button and in my php file that will run with else case).


That's not call

grid.store.load({
           params:{
                 start:0, 
                 limit:22, 
                 search1: myValue1,
                 search2: myValue2,
           }
    });


My idea to make search is not good? How can i fix that thank

1

1 Answers

0
votes

If you use params in the "load" function of the store, those are referred to the single request only so if you click next page of the toolbar you won't post the signalSearch param. You should register a custom listener on the before load event and add your params:

initComponent: function(){
      ....
      this.callParent(arguments);
      this.store.addListener('beforeload', function(store, operation){
           Ext.apply(operation.params, {
               signalSearch: 1 // Or you could make conditions if apply this search param
           });
           return true;
      }, this);
}