您的位置:首页 > 其它

Ext Ext.form.combobox使用注意事项

2012-04-17 21:23 323 查看
  今天在使用Struts2和Ext.js书写下拉框的时候,不管怎么样就是Combox中总也加载不上数据。没办法后,只能通过Ext.data.record的setvalue为其赋值,无意中发现只要赋值后,其他的选项也都加载上去。

  目前还不知道什么原因,需继续研究中。现将部分代码粘贴如下:

var groupRecord=new Ext.data.Record.create([
{name:'id',mapping:'id'},
{name:'groupName',mapping:'groupName'}
]);
var groupProxy=new Ext.data.HttpProxy({url:'/MedicalGuidance/manager/getUserGroup_userGroupAction.action?time='+new Date()})
var groupReader=new Ext.data.JsonReader(
{
totalProperty:"totalProperty",
root:"root",
id:'id'
},groupRecord)

var groupStore=new Ext.data.Store({
proxy:groupProxy,
reader:groupReader
});
groupStore.load(
{
params:{start:0,limit:100},
callback:function(r,options,success){
Ext.each(r,function(item){
})
}
})


  

var combox=new Ext.form.ComboBox({
fieldLabel:'用户组',
name:'userGroup',
store:groupStore,
displayField:'groupName',
valueField:'id',
mode:'remote'
});
combox.setValue("请选择用户组")


   而且,使用此控件传入后台数据时显示的数据。所以在使用JSON数据格式的时候Struts2对应本控件的属性应要是String类型的。

学习快乐吧。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: