Ext form加载数据 load方法 load加载数据要是数组形式的,不能是json对象
后台返回的数据必须是Collection形式的数据
如例子:
{
xtype:'form',
id:'load_form',
trackResetOnLoad : true,
border:false,
bodyStyle:'padding:10px 10px 10px 10px',
labelWidth:80,
autoScroll:true,
fileUpload:true,
reader: new Ext.data.JsonReader({root:'OBJECT'},
[{name: 'name',type:'string'},
{name: 'age',type:'string'},
{name: 'phone',type:'string'},
{name: 'address',type:'string'}
]),
items:[
{xtype:'textfield',fieldLabel:'姓名',name:'name'},
{xtype:'textfield',fieldLabel:'年龄',name:'age'},
{xtype:'textfield',fieldLabel:'电话',name:'phone'},
{xtype:'textfield',fieldLabel:'地址',name:'address'}
]
}
返回的值:OBJECT必须要是Collection数据,如:json数据,而不能是json对象这点一定要注意
[{name:'',age:'',phone:'',address:''}],而不能是{name:'',age:'',phone:'',address:''}

本文深入探讨了使用Ext.js构建表单时,如何正确配置JSON Reader以处理数组形式的数据,确保数据加载过程顺利进行。重点强调了返回数据必须为Collection形式的重要性,避免了将JSON对象直接作为数据源导致的问题。
253

被折叠的 条评论
为什么被折叠?



