ExtJS FormPanel动态添加字段后更改labelWidth

ExtJS FormPanel动态添加字段后更改labelWidth,extjs,formpanel,Extjs,Formpanel,我有一个动态FormPanel,在加载所有字段后,我需要在其中设置标签宽度。在调用this.doLayout之前,我尝试使用this.labelWidth=200,但它忽略了新值 有人能告诉我在哪里可以设置并重新绘制表单吗,谢谢。是否在呈现FormPanel后不再考虑labelWidthconfig选项?也许您可以使用FormPanel.findByType获取对所有标签的引用,将标签宽度设置为200,然后调用FormPanel.doLayout?是否在呈现FormPanel后不再考虑label

我有一个动态FormPanel,在加载所有字段后,我需要在其中设置标签宽度。在调用this.doLayout之前,我尝试使用this.labelWidth=200,但它忽略了新值


有人能告诉我在哪里可以设置并重新绘制表单吗,谢谢。

是否在呈现FormPanel后不再考虑
labelWidth
config选项?也许您可以使用
FormPanel.findByType
获取对所有标签的引用,将标签宽度设置为200,然后调用
FormPanel.doLayout

是否在呈现FormPanel后不再考虑
labelWidth
config选项?也许您可以使用
FormPanel.findByType
获取对所有标签的引用,将标签宽度设置为200,然后调用
FormPanel.doLayout

查看FormLayout的extjs源代码后,我发现一些变量可以设置为在调用表单上的doLayout之前更改标签宽度

因此,在FormPanel中,使用以下代码更改标签宽度:

Ext.apply(this.layout, {
    labelAdjust: this.labelWidth + 5,
    labelStyle: 'width:' + this.labelWidth + 'px;',
    elementStyle: 'padding-left:' + (this.labelWidth + 5) + 'px'
});

this.doLayout();

在查看了FormLayout的extjs源代码之后,我发现在对表单调用doLayout之前,可以设置一些变量来更改标签宽度

因此,在FormPanel中,使用以下代码更改标签宽度:

Ext.apply(this.layout, {
    labelAdjust: this.labelWidth + 5,
    labelStyle: 'width:' + this.labelWidth + 'px;',
    elementStyle: 'padding-left:' + (this.labelWidth + 5) + 'px'
});

this.doLayout();