Ext 表单动态加载

Ghost_520 2008-11-04 05:01:24

<script>
Ext.BLANK_IMAGE_URL = "resources/images/default/s.gif";
Ext.QuickTips.init();
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

Ext.onReady(function(){
var formPanel = new Ext.FormPanel({
id:"formTest",
title:"从后台加载数据",
width:400,
height:300,
renderTo:'panel',
// fields:['id','name','memo'],
reader: new Ext.data.JsonReader(
[
{
name: 'id',
mapping:'name/id',
type:'string'
},
{
name: 'name',
mapping:'name/name',
type:'string'
},
{
name: 'memo',
mapping:'name/memo',
type:'string'
}
]),

items:[
{
xtype:'textfield',
width:200,
fieldLabel : '编号',
name : 'id',
allowBlank : false
}, {
xtype:'textfield',
width:200,
fieldLabel : '名称',
name : 'name',
allowBlank : false
}, {
xtype:'textfield',
width:200,
fieldLabel : '备注',
name:'memo'
}
],
buttons:[
{
text:"加载数据",
listeners:{
click:function(){
loadData();
}
}
},
{
text:"提交"
},
{
text:"重置"
}
]
});

function loadData(){
Ext.getCmp("formTest").load({
url: "<%=path%>/loadData.do",
params: {param1: "foo", param2: "bar"} // 将参数传入到 URL 中
// callback: yourFunction, 回调函数
// scope: yourObject, // optional scope for the callback
/* discardUrl: false,
nocache: false,
text: "Loading...",
timeout: 10,
scripts: false */
})
}
})
</script>


好像是报 reader 不是属性,我就是想通过后台获得一个 json 数据并加载到这个表单上。
...全文
176 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ghost_520 2008-11-04
  • 打赏
  • 举报
回复
恭喜你 ,你答对了!
lizhi1026 2008-11-04
  • 打赏
  • 举报
回复
firebug上 调试下


reader:new Ext.data.JsonReader({},[]);
是不是掉了这个大括号?
Ghost_520 2008-11-04
  • 打赏
  • 举报
回复
帮忙顶下啊 ,谢谢啦。。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧