我使用以下代码将数据从我的商店加载到ExtJs中的表单,但我无法将数据检索到我的文本字段。
Ext.onReady(function() {
var formPanel = Ext.create('Ext.form.Panel', {
title: 'Form Panel',
width: 350,
height: 200,
style: 'margin: 50px',
renderTo: 'musicianProfile', // the name of the div in my JSP
reader: new Ext.data.JsonReader({
type: 'json',
root: 'data',
fields: [
{name: 'firstName', type: 'string'},
{name: 'lastName', type: 'string'}
]
}),
items: [{
xtype: 'container',
layout: 'hbox',
items: [{
fieldLabel: 'First Name',
xtype: 'textfield',
name: 'firstName',
readOnly: true,
flex: 1,
}, {
fieldLabel: 'Last Name',
xtype: 'textfield',
name: 'lastName',
readOnly: true,
flex: 1,
}]
}]
});
formPanel.getForm().load({
method:'GET',
url:'ajax/viewMusicianMembers.htm' //URL that produces a JSON result
});
});
我收到浏览器的价值是:
{
"success":true,"total":1,"message":null,
"data":[{"firstName":"System","lastName":"Administrator"}],
"errors":null
}
任何人都可以帮我找出错误的位置,以及如何纠正错误吗?
答案 0 :(得分:1)
试试这个,
formPanel.getForm().load({
method:'GET',
url:'ajax/viewMusicianMembers.htm', //URL that produces a JSON result
success: function(response, options) {
formPanel.getForm().setValues(Ext.JSON.decode(response.data));
},
failure: function (response, options) {
}
});