Extjs4 如何使用MVC在加载时填充Extjs表单
我一直面临着一场灾难 在MVC中填充extjs表单时出现问题。 我的要求是单击“查看配置文件” 它应该像firstname一样显示用户详细信息 以及表单中的姓氏。我无法填充 包含从服务器返回的json数据的表单。 请告诉我如何在加载时填充表单 这是我的店铺:Extjs4 如何使用MVC在加载时填充Extjs表单,extjs4,Extjs4,我一直面临着一场灾难 在MVC中填充extjs表单时出现问题。 我的要求是单击“查看配置文件” 它应该像firstname一样显示用户详细信息 以及表单中的姓氏。我无法填充 包含从服务器返回的json数据的表单。 请告诉我如何在加载时填充表单 这是我的店铺: Ext.define('EManage.store.UserStore', { extend: 'Ext.data.Store', model: 'EManage.model.UserModel',
Ext.define('EManage.store.UserStore', {
extend: 'Ext.data.Store',
model: 'EManage.model.UserModel',
storeId: 'userstore',
proxy: {
type: 'ajax',
url : 'http://localhost:8080/Users/viewprofile.do?method=ViewProfileForward', //the above action returns user details in json object
reader: {
type: 'json',
root: 'items'
}
},
autoLoad: true,
});
Ext.define('EManage.model.UserModel', {
extend : 'Ext.data.Model',
fields : [
'firstname',
'lastname',
]
});
这是我的模型:
Ext.define('EManage.store.UserStore', {
extend: 'Ext.data.Store',
model: 'EManage.model.UserModel',
storeId: 'userstore',
proxy: {
type: 'ajax',
url : 'http://localhost:8080/Users/viewprofile.do?method=ViewProfileForward', //the above action returns user details in json object
reader: {
type: 'json',
root: 'items'
}
},
autoLoad: true,
});
Ext.define('EManage.model.UserModel', {
extend : 'Ext.data.Model',
fields : [
'firstname',
'lastname',
]
});
以下是我的观点:
Ext.define('EManage.view.emodules.myProfile.UserProfile', {
extend: 'Ext.form.Panel',
xtype: 'form',
frame: true,
title: 'View Profile',
bodyPadding: 10,
autoScroll:true,
width: 355,
fieldDefaults: {
labelAlign: 'right',
labelWidth: 115,
msgTarget: 'side'
},
initComponent: function() {
this.items = [{
xtype: 'fieldset',
title: 'View Profile',
defaultType: 'textfield',
defaults: {
anchor: '100%'
},
items: [
{ allowBlank:false, fieldLabel: 'First Name', name: 'firstname'},
{ allowBlank:false, fieldLabel: 'Last Name', name: 'lastname'},
]
},
];
this.callParent();
},
}]
});
不要忘记在表单中指定每个字段的名称,就像在模型中指定的那样:
items: [{
fieldLabel: 'First Name',
xtype: 'textfield',
name: 'firstname'
}, {
fieldLabel: 'Last Name',
xtype: 'textfield',
name: 'lastName'
}]
请你把代码贴在加载数据的地方,然后插入表格。它是一个按钮,动作栏。。。?