擴展自 $.fn.combo.defaults。 用 $.fn.combobox.defaults 重寫了 defaults。

依賴
combo
用法
<select id="cc" name="dept" style="width:200px;">
<option value="aa">aitem1</option>
<option>bitem2</option>
<option>bitem3</option>
<option>ditem4</option>
<option>eitem5</option>
</select>
<input id="cc" name="dept" value="aa">
$('#cc').combobox({
url:'combobox_data.json',
valueField:'id',
textField:'text'
});
json 數(shù)據(jù)格式的示例
[{
"id":1,
"text":"text1"
},{
"id":2,
"text":"text2"
},{
"id":3,
"text":"text3",
"selected":true
},{
"id":4,
"text":"text4"
},{
"id":5,
"text":"text5"
}]
特性
其特性擴展自 combo,下列是為combobox 增加的特性。
名稱 | 類型 | 說明 | 默認值 |
valueField | string | 綁定到 ComboBox 的 value 上的基礎數(shù)據(jù)的名稱。 | value |
textField | string | 綁定到 ComboBox 的 text 上的基礎數(shù)據(jù)的名稱。 | text |
mode | string | 定義在文本改變時如何加載列表數(shù)據(jù)。如果組合框從服務器加載就設為 'remote' 。 | local |
url | string | 從遠程加載列表數(shù)據(jù)的 URL 。 | null |
method | string | 用來檢索數(shù)據(jù)的 http method 。 | post |
data | array | 被加載的列表數(shù)據(jù)。 | null |
filter | function | 定義當 'mode' 設為 'local' 時如何過濾數(shù)據(jù)。這個函數(shù)有兩個參數(shù): | |
formatter | function | 定義如何呈現(xiàn)行。這個函數(shù)有一個參數(shù):row。 |
事件
其事件擴展自 combo,下列是為 combobox 增加的事件。
名稱 | 參數(shù) | 說明 |
onLoadSuccess | none | 當遠程數(shù)據(jù)加載成功時觸發(fā)。 |
onLoadError | none | 當遠程數(shù)據(jù)加載失敗時觸發(fā)。 |
onSelect | record | 當用戶選擇一個列表項時觸發(fā)。 |
onUnselect | record | 當用戶取消選擇一個列表項時觸發(fā)。 |
方法
其方法擴展自 combo,下列是為 combobox 追加或重寫的方法。
名稱 | 參數(shù) | 說明 |
options | none | 返回 options 對象。 |
getData | none | 返回加載的數(shù)據(jù)。 |
loadData | data | 加載本地列表數(shù)據(jù)。 |
reload | url | 請求遠程的列表數(shù)據(jù)。 |
setValues | values | 把數(shù)組設置為組合框的值。 |
setValue | value | 設置組合框的值。 |
clear | none | 清除組合框的值。 |
select | value | 選擇指定的選項。 |
unselect | value | 取消選擇指定的選項。 |
|
新聞熱點
疑難解答