我自己写了个form组件,老是加载不上数据,下面是代码
js代码:
Ext.ux.ReservePlanForm = Ext.extend(Ext.form.FormPanel ,{
frame: true,
sepflag : 2,
width: 540,
autoHeigth: true,
layout: "form",
labelWidth: 70,
labelAlign: "left",
rid:null,
defaultType: "textfield",
waitMsgTarget : true,
reader: new Ext.data.JsonReader({root:'data'},[{name: 'rid',mapping:'rid'},{name: 'title',mapping:'title'},
{name: 'draftdpt',mapping:'draftdpt'},
{name: 'plantype',mapping:'plantype'},
{name: 'planno',mapping:'planno'},
{name: 'flowstate',mapping:'flowstate'},
{name: 'drafter',mapping:'drafter'},
{name: 'exeid',mapping:'exeid'}
]),
initComponent: function(){
this.items = [{
xtype:'textfield',//文本框
fieldLabel:'id',
id:'rid',
name:'rid',
readOnly :true
},{
xtype:'textfield',//文本框
fieldLabel:'标题',
id:'title',
name:'title',
readOnly :true
},{
xtype:'textfield',//文本框
fieldLabel:'拟稿部门',
id:'draftdpt',
name:'draftdpt',
readOnly : this.sepflag==1 ? false : true
},{
xtype:'textfield',//文本框
fieldLabel:'拟稿日期',
name:'draftdate'
},{
xtype:'textfield',//文本框
fieldLabel:'拟稿人',
id:'drafter',
name:'drafter'
},{
xtype:'textfield',//文本框
fieldLabel:'预案类型',
id:'plantype',
name:'plantype'
},{
xtype:'textfield',//文本框
fieldLabel:'预案编号',
id:'planno',
name:'planno'
},{
xtype:'textfield',//文本框
fieldLabel:'附件地址',
name:'annex'
},{
xtype:'textfield',//文本框
fieldLabel:'审批人',
name:'approver'
},{
xtype:'textfield',//文本框
fieldLabel:'下发时间',
name:'issuedate'
},{
xtype:'textfield',//文本框
fieldLabel:'归档部门',
name:'filedpt'
},{
xtype:'textfield',//文本框
fieldLabel:'备注',
name:'re'
}];
Ext.ux.ReservePlanForm.superclass.initComponent.call(this);
}
});Ext.reg('ReservePlanForm',Ext.ux.ReservePlanForm);jsp中的调用:
var form1 = new Ext.ux.ReservePlanForm({
renderTo:Ext.getBody()
});form1.getForm().load({
url : jsrootpath+'/servlet/getRP',
method : "GET",
params : { rid :'1001' },
waitMsg : '正在载入数据...',
success : function(form,action) {
Ext.Msg.alert('提示','载入成功');
},
failure : function(form,action) {
Ext.Msg.alert('提示','载入失败');
} });后台返回的数据:
{success:true,data:[{rid:'1001',title:'1',draftdpt:'1',plantype:'1',planno:'1',flowstate:'1',drafter:'1',exeid:'-'}]}
我直接用Ext.form.FormPanel的话没有任何问题,还是这些代码没变。用Ext.ux.ReservePlanForm的时候form能显示出来;后台程序也调用了,返回值没问题;能显示出“载入成功”的提示框,但就是没有数据。
js代码:
Ext.ux.ReservePlanForm = Ext.extend(Ext.form.FormPanel ,{
frame: true,
sepflag : 2,
width: 540,
autoHeigth: true,
layout: "form",
labelWidth: 70,
labelAlign: "left",
rid:null,
defaultType: "textfield",
waitMsgTarget : true,
reader: new Ext.data.JsonReader({root:'data'},[{name: 'rid',mapping:'rid'},{name: 'title',mapping:'title'},
{name: 'draftdpt',mapping:'draftdpt'},
{name: 'plantype',mapping:'plantype'},
{name: 'planno',mapping:'planno'},
{name: 'flowstate',mapping:'flowstate'},
{name: 'drafter',mapping:'drafter'},
{name: 'exeid',mapping:'exeid'}
]),
initComponent: function(){
this.items = [{
xtype:'textfield',//文本框
fieldLabel:'id',
id:'rid',
name:'rid',
readOnly :true
},{
xtype:'textfield',//文本框
fieldLabel:'标题',
id:'title',
name:'title',
readOnly :true
},{
xtype:'textfield',//文本框
fieldLabel:'拟稿部门',
id:'draftdpt',
name:'draftdpt',
readOnly : this.sepflag==1 ? false : true
},{
xtype:'textfield',//文本框
fieldLabel:'拟稿日期',
name:'draftdate'
},{
xtype:'textfield',//文本框
fieldLabel:'拟稿人',
id:'drafter',
name:'drafter'
},{
xtype:'textfield',//文本框
fieldLabel:'预案类型',
id:'plantype',
name:'plantype'
},{
xtype:'textfield',//文本框
fieldLabel:'预案编号',
id:'planno',
name:'planno'
},{
xtype:'textfield',//文本框
fieldLabel:'附件地址',
name:'annex'
},{
xtype:'textfield',//文本框
fieldLabel:'审批人',
name:'approver'
},{
xtype:'textfield',//文本框
fieldLabel:'下发时间',
name:'issuedate'
},{
xtype:'textfield',//文本框
fieldLabel:'归档部门',
name:'filedpt'
},{
xtype:'textfield',//文本框
fieldLabel:'备注',
name:'re'
}];
Ext.ux.ReservePlanForm.superclass.initComponent.call(this);
}
});Ext.reg('ReservePlanForm',Ext.ux.ReservePlanForm);jsp中的调用:
var form1 = new Ext.ux.ReservePlanForm({
renderTo:Ext.getBody()
});form1.getForm().load({
url : jsrootpath+'/servlet/getRP',
method : "GET",
params : { rid :'1001' },
waitMsg : '正在载入数据...',
success : function(form,action) {
Ext.Msg.alert('提示','载入成功');
},
failure : function(form,action) {
Ext.Msg.alert('提示','载入失败');
} });后台返回的数据:
{success:true,data:[{rid:'1001',title:'1',draftdpt:'1',plantype:'1',planno:'1',flowstate:'1',drafter:'1',exeid:'-'}]}
我直接用Ext.form.FormPanel的话没有任何问题,还是这些代码没变。用Ext.ux.ReservePlanForm的时候form能显示出来;后台程序也调用了,返回值没问题;能显示出“载入成功”的提示框,但就是没有数据。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货