Home > Web Front-end > JS Tutorial > body text

ext combobox dynamically loads database data (with front and backend)_extjs

WBOY
Release: 2016-05-16 16:43:58
Original
1831 people have browsed it

Front desk:

Copy code The code is as follows:

var provinceStore = new Ext.data.Store( {
proxy: new Ext.data.HttpProxy({ url: basePath "/stationManage/station_getProvinceJSON.action" }),
reader: new Ext.data.JsonReader(
{ root: "" },
["PROVINCEID", "PROVINCENAME"]
)
});


//Select province and city
var provinceIDadd = new Ext.form.ComboBox({
anchor : '98%',
id:'provinceIDadd',
name : "provinceIDAdd1",
hiddenName : "provinceID",
displayField : "PROVINCENAME",
valueField : "PROVINCEID",
blankText : 'Please select the province where the site belongs',
emptyText : 'Please select the province where the site belongs',
fieldLabel : 'The province where the site belongs',
allowBlank : false,
editable : false,
triggerAction : 'all',
store :provinceStore ,
forceSelection : true,
mode : 'local',
selectOnFocus : true
})
provinceStore.load();

Background action code
Copy code The code is as follows:

public class StationAction extends BaseAction {

private List> provinceList;
public void setProvinceList(List> provinceList) {
this.provinceList = provinceList;
}

public List> getProvinceList() {
return provinceList;
}
public String getProvinceJSON(){
String sql="SELECT PK_ID PROVINCEID,NAME PROVINCENAME FROM T_DICT_DISTRICT A WHERE A.DISTRICT_LEVEL=20";
provinceList= stationService.findBySQL(sql);
return "json_getProvinceList";
}
}

strtus xml configuration
Copy code The code is as follows:


provinceList


Load the drop-down selection box of static data
Copy the code The code is as follows:

var dataType=[['0','8 columns'],['1','38 columns'],['2','21 columns']];
var dataTypeStore = new Ext. data.SimpleStore({
fields: ['dataTypeID', 'dataTypeName'],
data : data
});

var dataTypedd = new Ext.form.ComboBox({
anchor : '98%',
id:'dataTypeadd',
name : "dataTypeAdd1",
hiddenName : "dataType",
displayField : "dataTypeName",
valueField : "dataTypeID",
blankText : 'Please select the data format',
emptyText : 'Please select the data format',
fieldLabel : 'Data format',
allowBlank : false,
editable : false,
triggerAction : 'all',
store :unitStore ,
forceSelection : true,
mode : 'local',
selectOnFocus : true
})
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template