What is ComboBox of Ext JS? To put it bluntly, it is the drop-down list + text, but more abundant!
How to use it?
[Javascript]
Ext. onReady (function (){
Var store = Ext. create ("Ext. data. Store ",{
Fields: ["abbr", "name"],
Data :[
{"Abbr": "wbg", "name": "wubangguo "},
{"Abbr": "wjb", "name": "wenjiabao "},
{"Abbr": "hjt", "name": "hujintao "},
{"Abbr": "lks", "name": "likeshan"}],
Sorters: ["abbr"] // sort
});
Ext. create ("Ext. form. ComboBox ",{
FieldLabel: "Choose Name ",
Store: store, // load the data source
QueryMode: "local", // if the data is local, you 'd better use this option to improve performance, the default situation is remote (note that the local option is also used when we return data to the local store through ajax requests, because if this is not the case, the server will be requested once more)
DisplayField: "name ",
ValueField: "abbr ",
ForceSelection: true, // select from the drop-down list only. text cannot be entered.
Editable: false, // editing is not allowed. The default value is true)
MultiSelect: true, // in this case, multiple items can be selected and displayed in combobox (false by default)
Listeners :{
Scope: this,
"Select": function (comboBox, record, index ){
Ext. Array. each (record, function (item ){
Alert (item. get ("name "));
});
Alert (comboBox. getValue (); // This is the value, not the value where it is displayed.
}
},
RenderTo: Ext. getBody ()
});
});