2013-07-05 23 views
1

我有一個GridPanel中,我在initComponet函數來創建店像ExtJS的電網 - 點擊與搜索條件翻頁按鈕

,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}}); 
    } 

我做了一些價值形式的搜索,當我按下搜索按鈕,下面我會做代碼

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

在我的PHP文件將趕上知道這是搜索

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

的d結果返回2頁(好)。但是,當我按下一頁按鈕看到第2頁上的一些結果但我的商店負載失敗(我認爲他們打電話store.load({params:{start:0, limit:22}});當我按下一頁按鈕和我的PHP文件,將與其他案件運行)。


這不叫

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


我的想法做搜索不是很好嗎?我該如何解決,謝謝

回答

0

如果您在商店的「加載」功能中使用參數,那些參數僅適用於單一請求,所以如果您單擊工具欄的下一頁,您將不會發布signalSearch參數。 您應該在加載前事件中註冊一個自定義偵聽器並添加您的參數:

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); 
}