Dve*_*Dve 6 forms extjs dynamic
我试图从数据存储记录动态填充ExtJs FormPanel.当用户单击GridPanel中的一行时,将调用buildForm方法,并将所单击的记录作为第一个arg传入.
下面的代码(调试时)似乎正在工作,但doLayout方法没有效果.
谁能指出我正确的方向?
mymodule = Ext.extend(Ext.FormPanel, {
forceLayout: true,
initComponent: function () {
Ext.applyIf(this, {
id: Ext.id(),
labelWidth: 75,
defaultType: 'textfield',
items: [{
layout: 'form',
items: [{
fieldLabel: 'test',
xtype: 'textfield'
}, {
fieldLabel: 'test',
xtype: 'textfield'
}]
}]
});
mymodule.superclass.initComponent.call(this);
},
buildForm: function (record, c) {
var form = this.getForm();
var formItems = new Ext.util.MixedCollection();
Ext.each(record.fields.items, function (item) {
formItems.add(new Ext.form.TextField({
labelStyle: 'width:100px',
fieldLabel: item.name,
name: item.dataIndex,
id: 'field-' + item.name
}));
}, this);
form.items = formItems;
this.doLayout(false, true);
form.loadRecord(record);
}
});
Run Code Online (Sandbox Code Playgroud)
向表单添加组件的正确方法是使用该add()方法.如果您的表单已经呈现,请使用该add()方法然后调用doLayout().
所以你可能想试试这个:
form.add(formItems);
form.doLayout(false,true);
form.loadRecord(record);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6033 次 |
| 最近记录: |