var fabircTypeDs = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'province.do'
}),
reader: new Ext.data.JsonReader({},['pname','pid']),
remoteSort: false
});
fabircTypeDs.load();
formPanel = new Ext.form.FormPanel({
bodyStyle:'padding-top:6px;',//设置控件边类型
defaultType:'textfield',//FormPanel内元素默认类型
labelAlign:'right',//设置控件的标题对齐方式
labelWidth:55,// 指定标签的默认长度
labelPad:0,// 标签与字段录入框之间的空白
frame:true,//设置控件边角圆弧过度
defaults:{//FormPanel默认设置
allowBlank:true,
width:158
},
items:[
new Ext.form.ComboBox({
name:'provincename',
fieldLabel:'省份',
store:fabircTypeDs,
blankText:'全部',
mode:'remote',
editable:false,
selectOnFocus:true
}),
上面代码还要指定displayField:"name",valueField:"id"
fabircTypeDs.load(); 表示打开页面时就将数据取到本地,这样下拉列表时就不需要取去服务器取数据,如果要没加上这一句的话,去下拉那个列表时就会动态去服务器取数据,所以它会显示一下'loading...',这样就明白为什么要设置mode了。
mode:'remote'指的是要动态去服务器端拿数据,这样就不能加fabircTypeDs.load(),
而mode:'local'是取本地数据的也就是javascirpt(内存)中的数据,可以指定store的autoLoad:true,如下:
var family_relation_store = new Ext.data.JsonStore({
autoDestroy: true,
autoLoad: true,
root: 'Table',
totalProperty: 'totalCount',
proxy: new Ext.data.HttpProxy({ url: '../Appointment/FamilyRelationList' }),
fields: ['familyrelationtypeid', 'displayName']
});