Extended from $.fn.combo.defaults. Rewrite the defaults with $.fn.combobox.defaults.
Depend on
Combo
Usage
The code is as follows |
Copy Code |
<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 ' }); Example of JSON data format [{ "id": 1, "Text": "Text1" },{ "id": 2, "Text": "Text2" },{ "id": 3, "Text": "Text3", ' Selected ': True },{ "id": 4, "Text": "Text4" },{ "id": 5, "Text": "Text5" }] |
Its features extend from combo, and the following are the features that are added for ComboBox.
Name
|
Type
|
Description
|
Default value
|
Valuefield
|
String
|
The name of the underlying data on value that is bound to ComboBox.
|
Value
|
TextField
|
String
|
The name of the underlying data that is bound to ComboBox text.
|
Text
|
Mode
|
String
|
Defines how the list data is loaded when text changes. If the combo box is loaded from the server, it is set to ' remote '.
|
Local
|
Url
|
String
|
The URL from which the list data is loaded remotely.
|
Null
|
Method
|
String
|
The HTTP method used to retrieve the data.
|
Post
|
Data
|
Array
|
The list data that was loaded.
|
Null
|
Filter
|
function
|
Defines how data is filtered when ' mode ' is set to ' local '. This function has two parameters:
Q: Text entered by the user
Row: The line data in the list.
Returns true to allow the row to be displayed.
|
|
Formatter
|
function
|
Defines how rows are rendered. This function has one argument: row.
|
|
Its events are extended from combo, and the following are the events that are incremented for ComboBox.
Name
|
Parameters
|
Description
|
Onloadsuccess
|
None
|
Triggered when remote data is loaded successfully.
|
Onloaderror
|
None
|
triggered when a remote data load fails.
|
Onselect
|
Record
|
Triggered when the user selects a list item.
|
Onunselect
|
Record
|
Triggered when a user cancels the selection of a list item.
|
The method extends from combo, and the following methods are appended or overridden for ComboBox.
Name
|
Parameters
|
Description
|
Options
|
None
|
Returns the Options object.
|
GetData
|
None
|
Returns the loaded data.
|
LoadData
|
Data
|
Loads the local list data.
|
Reload
|
Url
|
Request remote list data.
|
Setvalues
|
Values
|
Sets the array to the value of the combo box.
|
SetValue
|
Value
|
Sets the value of the combo box.
|
Clear
|
None
|
Clears the value of the combo box.
|
Select
|
Value
|
Select the specified option.
|
Unselect
|
Value
|
Deselect the specified option.
|