Ext combobox Dynamic loading of database data (with front and back desk) _extjs

Source: Internet
Author: User
Front desk:
Copy Code code 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"]
)
});


Choose provinces and cities
var provinceidadd = new Ext.form.ComboBox ({
Anchor: ' 98% ',
ID: ' Provinceidadd ',
Name: "ProvinceIDAdd1",
Hiddenname: "Provinceid",
Displayfield: "Provincename",
Valuefield: "Provinceid",
Blanktext: ' Please select the province to which the site belongs ',
Emptytext: ' Please select the province to which the site belongs ',
Fieldlabel: ' Site-owned province ',
Allowblank:false,
Editable:false,
TriggerAction: ' All ',
Store:p Rovincestore,
Forceselection:true,
Mode: ' Local ',
Selectonfocus:true
})
Provincestore.load ();

Background Action Code
Copy Code code 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 Code code as follows:

<result name= "json_getprovincelist" type= "JSON" >
<param name= "Root" >provinceList</param>
</result>

Drop down selection box to load static data
Copy Code code 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: "Datatypeadd 1 ",
Hiddenname:" DataType ",
Displayfield:" Datatypename ",
Valuefield:" Datatypeid ",
Blanktext: ' Please select data format ',
Emptytext: ' Select data format ',
Fieldlabel: ' Data format ',
Allowblank:false,
Editable:false, triggeraction: ' All ',
Store:unitstore,
Forceselection:true,
Mode: ' Local ',
Selectonfocus: True
})

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.