gpt4 book ai didi

javascript - EXTJS:如何从 JSON 文件加载 Ext.form.panel 项目配置

转载 作者:行者123 更新时间:2023-11-30 16:38:21 26 4
gpt4 key购买 nike

下面是我的表单定义,其中我想从 json 文件中为 items 属性赋值,该文件包含有关 fieldLabel、名称、xtype 等的信息,所以我可以通过任何方式做到这一点?

Ext.define('com.myproject.view.myform', {
extend:'Ext.form.Panel',
alias: 'widget.myform',
xtype : 'myform',
autoShow : true,
width: 500,
height: 400,
title: 'Foo',
floating: true,
closable : true,
items: [{
fieldLabel: 'ID',
name: 'filterID',
xtype : 'textfield',
allowBlank: false
},{
fieldLabel: 'LABEL',
name: 'filterLabel',
xtype : 'textfield',
allowBlank: false
}] });

JSON 文件

{"itemsConfiguration": [{
"fieldLabel": "ID",
"name": "filterID",
"xtype" : "textfield",
"allowBlank": false
},{
"fieldLabel": "LABEL",
"name": "filterLabel",
"xtype" : "textfield",
"allowBlank": "false"
}]}

最佳答案

Ext.define('com.myproject.view.myform', {
extend:'Ext.form.Panel',
alias: 'widget.myform',
xtype : 'myform',
autoShow : true,
width: 500,
height: 400,
title: 'Foo',
floating: true,
closable : true,
initComponent:function() {
var me = this,
args = arguments;
Ext.Ajax.request({
// TODO fill url etc.
callback:function(response) {
Ext.apply(me,{
items:Ext.decode(response.responseText).itemsConfiguration
});
me.callParent(args);
}
});
},
});

关于javascript - EXTJS:如何从 JSON 文件加载 Ext.form.panel 项目配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32374560/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com