[英]Populate a form from store in ExtJS 4
我已使用以下代碼將存儲中的數據加載到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
}
誰能幫助我找出錯誤所在,以及如何糾正錯誤?
試試這個
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) {
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.