2013-06-26 79 views
-1

你好,我想做的搜索結果在combobox.It的工作,但我也需要在所有頁面搜索搜索僅在本頁面我使用分頁與搜索不是當前頁面只有搜索在組合框中與分頁ExtJS的

任何建議


{ 
    xtype: 'combo', 
    fieldLabel: 'Organization Id', 
    name: 'company_id', 
    displayField:'name_en', 
    valueField:'id', 
    store: Ext.create('UserApp.store.PicklistList', { 
     autoLoad: true, 
     fields: ['id', 'name_en', 'name_se'], 
     proxy:{ 
      type:'ajax', 
      api: { 
       read:'picklist/listitems' 
      }, 
      reader: { 
       type: 'json', 
       root: 'root', 
       successProperty: 'success' 
      }, 
      extraParams:{ 
       table :'table_name' 
      } 
     } 
    }), 
    editable: true, 
    autoSelect: false, 
    selectOnFocus:true, 
    typeAhead:true, 
    minChars:2, 
    queryMode: 'local', 
    mode: 'local', 
    pageSize: 25, 
    width:370, 
    allowOnlyWhitespace: false, 
    regex: /[a-zA-Z0-9]+/, // avoid to empty data only 
}) 
+0

如果您可以發佈您的代碼,診斷將會容易得多。你使用遠程或本地商店? – kevhender

+0

添加了代碼我正在使用遠程存儲和querymode它是本地的 – DeveloperSystem

+0

如何定義this.store?在initComponent中爲 – kevhender

回答

0
  1. 你的店需要設置爲pagination

  2. 您的服務器需要根據從商店代理接收的參數正確處理分頁。代理將發送像?page=1&start=0&limit=25這樣的查詢字符串參數,並且您的服務器只需要返回25個(例如)記錄和一個總參數。

    {"total":101,"data":[{model data}, {model data}, ...]}

  3. 儘管文檔,在組合框中pageSize屬性實際上是一個布爾值,如果上大於或等於1轉彎分頁。

0

我在使用combobox和queryMode:'remote',並使用combobox搜索匹配項。我正在做一個'contains'搜索 - 意味着它在結果字符串中的任何地方尋找匹配不僅僅是開始,而且它不僅在當前頁面而且在整個結果集中搜索值。我使用extjs 4.0.7,並通過覆蓋doQuery方法來實現它。

`doQuery:function(queryString,forceAll){ this.expand();這個.store.clearFilter(!forceAll);

if(this.queryMode == 'remote') { 
     this.store.load({ 
      params: this.getParams(queryString) 
     }); 
    } 
    if (!forceAll) { 
     this.store.filter(this.displayField, new RegExp(Ext.String.escapeRegex(queryString), 'i')); 
    } 
}`