2013-03-14 36 views
0

需要在Java中使用GWT創建Combobox。此組合框必須具有鍵入功能,並且還必須使用「包含」而不是「startswith」作爲建議。任何想法如何實現這一點?我是否應該重寫某些內容? 在此先感謝Gwt combobox比較使用包含而不是startswith

---編輯加入我的代碼 首先我聲明瞭組合框和存儲

private ComboBox docTypeField; 
private Store store; 

然後我initialazing組合框以這種方式

docTypeField = new ComboBox(); 
docTypeField.setFieldLabel("Doc Types:"); 
docTypeField.setDisplayField(DocTypePicker.STORE_FIELD_NAME); 
docTypeField.setMode(ComboBox.LOCAL); 
docTypeField.setStore(store); 
docTypeField.setTypeAhead(true); 
某些部分

我試圖通過方法在店裏修改過濾器,但預期它沒有工作

store.filterBy(new StoreTraversalCallback() { 
      public boolean execute(Record record) { 
       //if user text matches the name or alias then its true 
       if (sugestDocttype.getValue() == null 
         || sugestDocttype.getValue().length() == 0 
         || (record.getAsString(DocTypePicker.STORE_FIELD_NAME) != null && record.getAsString(
           DocTypePicker.STORE_FIELD_NAME).toUpperCase().contains(
             sugestDocttype.getValue().toUpperCase())) 
         ){ 

        return true; 
       } 

       return false; 
      } 
     }); 
+0

到目前爲止你試過的東西?你能告訴我們你的解決方法嗎? – 2013-03-14 13:52:01

+0

我試圖使用一個提示框,而不是組合框,但它沒有鍵入選項 – mlopezc 2013-03-14 14:09:11

+1

他「你試過什麼」的意思是「你能提供你的代碼片段(與發生的問題)所以我們可以幫你解決它?「 – 2013-03-14 14:17:05

回答