EXT自定义窗体加载数据

本文探讨了在ExtJS中自定义窗体加载ComboBox数据时遇到的问题及可能的原因。作者定义了一个包含dataurl属性的自定义窗口,用于指定数据加载的URL,但ComboBox无法正确显示数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我定义了一个自定义窗体,代码如下,其中有一个dataurl属性,是自定义的,主要的功能就是传递自定义窗体要加载数据的url

EditBranchWindow = Ext.extend(Ext.Window, {
title : '修改',
width : 350,
height : 140,
dataurl : '',
collapsible : true,
modal : true,
defaults : {
border : false
},
buttonAlign : 'center',
createFormPanel : function() {
var myproxy = new Ext.data.HttpProxy({
url : this.dataurl,
method : 'POST'
})
var myds = new Ext.data.Store({
proxy : myproxy,
reader : new Ext.data.JsonReader({
root : 'users',
totalProperty : 'total',
successProperty : 'success',
id : 'id'
}, [{
name : 'name',
mapping : 'name'
}, {
name : 'email',
mapping : 'email'
}, {
name : 'id',
mapping : 'id'
}])
});
/*
* var sstore = new Ext.data.SimpleStore({ proxy:proxy });
*/
myds.load();
var mcombo = new Ext.form.ComboBox({
store : myds,
displayField : 'name',
emptyText : '请选择一个用户...',
// valueField : 'id',
fieldLabel : '支部管理员',
id : 'master.id',
name : 'master.id'
});

var editpanel = new Ext.form.FormPanel({
bodyStyle : 'padding-top:6px',
defaultType : 'textfield',
labelAlign : 'right',
labelWidth : 100,
labelPad : 0,
frame : true,
defaults : {
allowBlank : false,
width : 158
},
items : [{
name : 'branch.title',
fieldLabel : '支部名称',
blankText : '支部名称不能为空'
}, mcombo]
});
return editpanel;
},
subdata : function() {
if (this.fp.form.isValid()) {
this.fp.form.submit({
waitMsg : '正在提交数据...',
url : 'saveBranch.action',
success : function(form, action) {
window.location.reload();
},
failure : function(form, action) {
form.reset();
Ext.MessageBox.show({
title : '警告',
msg : '发生错误!',
buttons : Ext.MessageBox.OK,
icon : Ext.MessageBox.ERROR
});
}
});
} else {
Ext.MessageBox.alert('提示', '请填写完整');
}
},
initComponent : function() {
EditBranchWindow.superclass.initComponent.call(this);
this.fp = this.createFormPanel();
this.add(this.fp);
this.addButton('提交', this.subdata, this);
this.addButton('重置', function() {
this.fp.form.reset();
}, this);
}
});

在工具栏的按钮单击事件以后加载数据,代码如下:

var newButtonclick = function() {
var win = new EditBranchWindow({
title : '添加',
dataurl : 'new.action'
});
win.show();
};

new.action返回的数据也是正常的,但是combobox无法显示数据,是什么原因?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值