Home  >  Article  >  Web Front-end  >  Introduction to the usage of store data format of drop-down list ComboBox component in Ext_extjs

Introduction to the usage of store data format of drop-down list ComboBox component in Ext_extjs

WBOY
WBOYOriginal
2016-05-16 17:28:501665browse
Copy code The code is as follows:

var p_years = new Ext.form.ComboBox( {
fieldLabel : 'statistical year',
anchor : anchor_w,
mode : 'remote',
maxHeight:100,
triggerAction : 'all',
selectOnFocus : true,
forceSelection : true,
editable : false,
//store :[['11', '2011'], ['12', '2012'],['13', '2013']] //This The first type
store:[2011,2012,2013,2014,2015,2016,2017,2018] //This is the second type. When value and text are not specified, the default submission value and display value are The same.
});

In this component, you can directly write the array format [[' value','Text '],[ ],[ ]] to construct and submit the value. is the former, and the latter is used as the display value.
The following is a more formal usage, synchronizing the data dictionary from the database to render the comboBox component
Copy the code The code is as follows:

var proj_main_store = new Ext.data.JsonStore({
url : "************",
fields : ['TEXT', 'VALUE'] ,
root : "objs",
baseParams : {
"obj/dicttypeid" : "BM_IMPORTANT_PROJ"
}
});
proj_main_store.addListener("load", function (){
proj_main_store.insert(0, new Ext.data.Record({
'TEXT' : 'All',
'VALUE' : ""
}));
});
var proj_main_type = new Ext.form.ComboBox( {
fieldLabel : 'Key Project',
anchor : anchor_w,
mode : 'remote',
triggerAction : 'all ',
selectOnFocus : true,
forceSelection : true,
editable : false,
valueField : 'VALUE',
displayField : 'TEXT',
store : proj_main_store
});
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn