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:'全部',
emptyText:'全部',
mode:'remote',
editable:false,
selectOnFocus:true
}),
上面是我创建Store和ComboBox的代码,想要通过proince.do从数据库读取数据,后台采用SpringMVC等框架,现在是页面出来没问题,但是
ComboBox的数据没有加载上,也就是请求根本没有到达后台,希望哪位能指点一下,我想不到哪里出了问题,mode属性我也设置了remote。
解决方案:
这里的关键点在这里:
fabircTypeDs.load();
mode:'remote',
mode:'local' 或者client
fabircTypeDs.load();
表示你打开页面时就将数据取到本地,这样你下拉列表时就不需要取去服务器取数据,如果你要没加上这一句的话,你去下拉那个列表时就会动态去服务器取数据,
所以它会显示一下'loading...',这样你就明白为什么要设置mode了,mode:'remote'指的是要动态去服务器端拿数据,这样你就不
能加fabircTypeDs.load(),而mode:'local'是取本地数据的也就是javascirpt(内存)中的数据,这样当然不要加上
fabircTypeDs.load()啦!
还要指定displayField:"name",valueField:"id"吧
来源:http://www.iteye.com/topic/187723
引用自:http://blog.163.com/xiao_mege/blog/static/72942753201132983543104/