2012-10-01 57 views
1

我正在使用組合框功能的Ajax工具箱,顯示的項目大約爲40,000個,所以我想對過濾器應用相同的過濾器,以便用戶在組合框中鍵入字母並在組合框中顯示起始字母「a」的相應條目。在asp.net中過濾Ajax組合框

我可以有一個想法,我不使用Radcombobox,它是一個最簡單的組合框。

<asp:ComboBox ID="AppComCombx" runat="server" 
           CssClass="dropdownpersonal textfont" 
           onselectedindexchanged="AppComCombx_SelectedIndexChanged" AutoPostBack="true"> 
</asp:ComboBox> 
+1

上的所有項目,您應該使用'自動完成Externder'爲,而不是'Combobox'。 – yogi

+0

@ yogi:我只能使用ajax。:( –

+0

是的,Ajax Toolkit中有一個'AutoComplete Extener'轉到這裏:http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AutoComplete/AutoComplete.aspx – yogi

回答

0

試試這個:AutoCompleteMode = "SuggestAppend"

喜歡這個

<ajaxToolkit:ComboBox ID="ComboBox1" runat="server" 
    AutoPostBack="False" 
    DropDownStyle="DropDownList" 
    AutoCompleteMode="SuggestAppend" 
    CaseSensitive="False" 
    CssClass="" 
    ItemInsertLocation="Append" /> 

欲瞭解更多信息請here

+0

這是做了一些我想要的,當我在組合框中鍵入某些東西時它會顯示結果,但對於整個功能,我希望如果我輸入A,那麼只有以A開頭的條目應該在列表中。 –

0

加入對js文件的ScriptManager參考用下面的腳本,並使用SuggestNone模式對於組合

Sys.Application.add_load(function() { 
    Sys.Extended.UI.ComboBox.prototype._ensureHighlightedIndex = function() { 
     // highlight an index according to textbox value 
     var textBoxValue = this.get_textBoxControl().value; 

     // first, check the current highlighted index 
     if (this._highlightedIndex != null && this._highlightedIndex >= 0 
      && this._isExactMatch(this._optionListItems[this._highlightedIndex].text, textBoxValue)) { 
      return; 
     } 

     // need to find the correct index 
     var firstMatch = -1; 
     var ensured = false; 
     var children = this.get_optionListControl().childNodes; 

     for (var i = 0; i < this._optionListItems.length; i++) { 
      var itemText = this._optionListItems[i].text; 
      children[i].style.display = this._isPrefixMatch(itemText, textBoxValue) ? "list-item" : "none"; 

      if (!ensured && this._isExactMatch(itemText, textBoxValue)) { 
       this._highlightListItem(i, true); 
       ensured = true; 
      } 
      // if in DropDownList mode, save first match. 
      else if (!ensured && firstMatch < 0 && this._highlightSuggestedItem) { 
       if (this._isPrefixMatch(itemText, textBoxValue)) { 
        firstMatch = i; 
       } 
      } 
     } 

     if (!ensured) { 
      this._highlightListItem(firstMatch, true); 
     } 
    }; 
}); 

AutoCompleteExtender在這種情況下,所有的方式組合框更好的選擇將呈現頁面

+0

非常感謝,我已經完成了這項工作! –