Ext combobox dynamic loading of database data (with the front and back end)

Source: Internet
Author: User

Front-end:
Copy codeThe 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 a province/City
Var provinceIDadd = new Ext. form. ComboBox ({
Anchor: '20140901 ',
Id: 'provinceidadd ',
Name: "provinceIDAdd1 ",
HiddenName: "provinceID ",
DisplayField: "PROVINCENAME ",
ValueField: "PROVINCEID ",
BlankText: 'select the province to which the site belongs ',
EmptyText: 'select the province to which the site belongs ',
FieldLabel: 'province to which the site belongs ',
AllowBlank: false,
Editable: false,
TriggerAction: 'all ',
Store: provinceStore,
ForceSelection: true,
Mode: 'local ',
SelectOnFocus: true
})
ProvinceStore. load ();

Background action code
Copy codeThe Code is as follows:
Public class StationAction extends BaseAction {

Private List <Map <String, Object> provinceList;
Public void setProvinceList (List <Map <String, Object> provinceList ){
This. provinceList = provinceList;
}

Public List <Map <String, Object> 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 codeThe Code is as follows:
<Result name = "json_getProvinceList" type = "json">
<Param name = "root"> provinceList </param>
</Result>

Drop-down box for loading static data
Copy codeThe Code is as follows:
Var dataType = [['0', '8 columns '], ['1', '38 columns'], ['2', '21 columns '];
Var dataTypeStore = new Ext. data. SimpleStore ({
Fields: ['peypeid', 'datatypename'],
Data: data
});

Var dataTypedd = new Ext. form. ComboBox ({
Anchor: '20140901 ',
Id: 'peypeadd ',
Name: "dataTypeAdd1 ",
HiddenName: "dataType ",
DisplayField: "dataTypeName ",
ValueField: "dataTypeID ",
BlankText: 'select data format ',
EmptyText: 'select data format ',
FieldLabel: 'Data format ',
AllowBlank: false,
Editable: false,
TriggerAction: 'all ',
Store: unitStore,
ForceSelection: true,
Mode: 'local ',
SelectOnFocus: true
})

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.