1、定义接口json格式;
{"success":true,"info":[{"elongInfo":"elong test","ctripInfo":"ctrip test"}]}
a、需要success,判读是否成功;
b、root节点info下是一个数组;
2、定义reader;
new Ext.data.JsonReader({
successProperty: 'success',
root: 'info'
},['elongInfo',
'ctripInfo'
])
a、successProperty和root属性与上面的json格式对应
3、定义items;
4、进行加载;
displayPanel.getForm().load({
url:'review.jsp?id=xyz'
});
完整实例:
var displayPanel = new Ext.FormPanel({
layout: 'form',
reader: new Ext.data.JsonReader({
successProperty: 'success',
root: 'info'
},['elongInfo',
'ctripInfo'
]),
items:[{
xtype: 'textarea',
fieldLabel: 'elong',
height: 100,
anchor: '95%',
name: 'elongInfo'
},{
xtype: 'textarea',
fieldLabel: 'ctrip',
height: 100,
anchor: '95%',
name: 'ctripInfo'
}
]
});
displayPanel.getForm().load({
url:'review.jsp?id=xyz'
});
{"success":true,"info":[{"elongInfo":"elong test","ctripInfo":"ctrip test"}]}
a、需要success,判读是否成功;
b、root节点info下是一个数组;
2、定义reader;
new Ext.data.JsonReader({
successProperty: 'success',
root: 'info'
},['elongInfo',
'ctripInfo'
])
a、successProperty和root属性与上面的json格式对应
3、定义items;
4、进行加载;
displayPanel.getForm().load({
url:'review.jsp?id=xyz'
});
完整实例:
var displayPanel = new Ext.FormPanel({
layout: 'form',
reader: new Ext.data.JsonReader({
successProperty: 'success',
root: 'info'
},['elongInfo',
'ctripInfo'
]),
items:[{
xtype: 'textarea',
fieldLabel: 'elong',
height: 100,
anchor: '95%',
name: 'elongInfo'
},{
xtype: 'textarea',
fieldLabel: 'ctrip',
height: 100,
anchor: '95%',
name: 'ctripInfo'
}
]
});
displayPanel.getForm().load({
url:'review.jsp?id=xyz'
});