以JSON的值初始化Ext.Form`

在Form的定义部分添加一个Reader

程序代码
var fs = new Ext.FormPanel({
frame: true,
title:'XML Form',
labelAlign: 'right',
labelWidth: 85,
width:340,
waitMsgTarget: true,
reader : new Ext.data.JsonReader({
root : 'article',
success : '@success'
}, [
{
name : 'title',
mapping : 'title'
}]),
items: [
new Ext.form.FieldSet({
title: 'Contact Information',
autoHeight: true,
defaultType: 'textfield',
items: [{
fieldLabel: ''title'',
name: 'first',
width:190
})
]
})
]
});
 

通过调用

程序代码
fs.getForm().load({url:'loadArticle.action?articleId=6', waitMsg:'Loading'});
 

就可以取到返回的JSON值并设置给Form``

不过这里要注意一点的就是``JSONREADER中的root项要对应一个数组`也就是说JSON的返回格式``要以`

程序代码
{"article":[
{"title":"title111"}
]}
 

不能是`

程序代码
{"article":
{"title":"title111"}
}
 

转载于:https://my.oschina.net/piorcn/blog/310553

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值