2012-08-30 45 views
3

我必須從一組插入頁面頂部的textfield/combobox過濾一個網格存儲在單獨的Ext.form.Panel中。 我用這個代碼做電網濾波器:在extjs4.1服務器端的過濾器存儲

doGridFilters : function() { 
     //storeClients.clearFilter(); 
     var client_Id = Ext.getCmp('Id_form').getValue(); 
     var filter1 = Ext.create('Ext.util.Filter',{ 
      root:'list', 
      comparison: 'eq', 
      property: "Id", 
      value: client_Id 
     }); 

     storeClients.getProxy().extraParams = { filter: filter1 }; 
     storeClients.load(); 
    }, 

但店內不執行任何類型的過濾器。

任何人都可以幫助我嗎?

+0

什麼服務器端是否接收參數? – Reimius

+0

在這裏使用Ext.util.filter有特定的原因嗎?我看到你只需要'client_Id'屬性。將它作爲 傳遞給storeClients.getProxy()。extraParams.filter = client_Id;並處理服務器端的「過濾器」。 – jssridhar

回答

3

Remotefiltering是很容易的:

  • 商店必須remoteFilter進行配置,以便代理 將處理和傳遞所有應用的過濾
  • 下一頁應用過濾器 store.filter('propertyName', 'filtervalue')。該商店現在將在應用篩選器後自動加載 。
  • 在它看起來像 ...filter:[{property:'Name', value:'value'}]...

的服務器端期望的 過濾器列表,而這一切。在應用過濾器之前,可以每次更改remoteFilter屬性。對於您的情況:

doGridFilters : function(grid) { 
    var store = grid.store; 
    store.clearFilter(); 
    store.remoteFilter = true;// optional 
    var client_Id = Ext.getCmp('Id_form').getValue(); 
    store.on('load', function(s){ s.remoteFilter = false; }, this, { single: true }) // optional 
    store.filter("Id",client_Id); 
} 

注: 代理將永遠只能應用屬性值配對的過濾器,僅此而已[ExtJS的4.1.1]欲瞭解更多,您將需要重寫負責代理功能