ExtJS 3.4:如何动态更改字段集大小
ExtJS 3.4 : How to change fieldset size dynamically
我正在尝试将项目动态添加到 fielset
中。我已经在控制台中检查了字段集的项目,该项目正在添加到字段集中但没有显示,我正在为字段集和 formpanel
调用 doLayout()
方法有这个fieldset,但是fieldset的size/height没有变化。有人可以帮我解决这个问题吗?
if(csType.value=="OS"){
Ext.apply(newOs,that.osCombo);
newOs.id = 'testOs2';
Ext.getCmp('cSFieldSet').add(newOs);
Ext.getCmp('cSFieldSet').setHeight(600);
Ext.getCmp('cSFieldSet').doLayout(true,true);
Ext.getCmp('cSFieldSet').ownerCt.doLayout(true,true);
that.csFormPanel.doLayout(true,true);
}
我也试过使用 autoHeight: true
,但仍然没有显示该项目
这是我刚刚编写的一些测试代码,用于模拟您要实现的目标:
var simple = new Ext.FormPanel({
labelWidth: 75,
frame:true,
title: 'Simple Form',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
// Fieldset in Column 1
xtype:'fieldset',
itemId: 'fieldSetTest',
columnWidth: 0.5,
title: 'Fieldset 1',
collapsible: false,
autoHeight:false,
defaultType: 'textfield',
items :[{
fieldLabel: 'Field 1'
}, {
fieldLabel: 'Field 2'
}, {
fieldLabel: 'Field 3'
}
]
}
],
buttons: [{
text: 'Add New Field',
handler: function() {
var newItem = new Ext.form.TextField({fieldLabel: 'New Fields'});
simple.getComponent('fieldSetTest').add(newItem);
simple.doLayout();
},
scope:this
}]
});
simple.render(document.body);
});
这很好用,所以在单击添加按钮时,新项目会出现在字段集中,并且字段集的高度会自动增加。没有看到您的整个表单面板代码,我无法进一步评论。
我正在尝试将项目动态添加到 fielset
中。我已经在控制台中检查了字段集的项目,该项目正在添加到字段集中但没有显示,我正在为字段集和 formpanel
调用 doLayout()
方法有这个fieldset,但是fieldset的size/height没有变化。有人可以帮我解决这个问题吗?
if(csType.value=="OS"){
Ext.apply(newOs,that.osCombo);
newOs.id = 'testOs2';
Ext.getCmp('cSFieldSet').add(newOs);
Ext.getCmp('cSFieldSet').setHeight(600);
Ext.getCmp('cSFieldSet').doLayout(true,true);
Ext.getCmp('cSFieldSet').ownerCt.doLayout(true,true);
that.csFormPanel.doLayout(true,true);
}
我也试过使用 autoHeight: true
,但仍然没有显示该项目
这是我刚刚编写的一些测试代码,用于模拟您要实现的目标:
var simple = new Ext.FormPanel({
labelWidth: 75,
frame:true,
title: 'Simple Form',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
// Fieldset in Column 1
xtype:'fieldset',
itemId: 'fieldSetTest',
columnWidth: 0.5,
title: 'Fieldset 1',
collapsible: false,
autoHeight:false,
defaultType: 'textfield',
items :[{
fieldLabel: 'Field 1'
}, {
fieldLabel: 'Field 2'
}, {
fieldLabel: 'Field 3'
}
]
}
],
buttons: [{
text: 'Add New Field',
handler: function() {
var newItem = new Ext.form.TextField({fieldLabel: 'New Fields'});
simple.getComponent('fieldSetTest').add(newItem);
simple.doLayout();
},
scope:this
}]
});
simple.render(document.body);
});
这很好用,所以在单击添加按钮时,新项目会出现在字段集中,并且字段集的高度会自动增加。没有看到您的整个表单面板代码,我无法进一步评论。