1

放置 labelAlign: 'top' 时,FieldContainer 无法正确显示。

找到我的小提琴:https ://fiddle.sencha.com/#fiddle/1c2s 我创建了一个基于字段容器的自定义字段。如果将窗口调整为更小的尺寸,您会看到文本字段将位于 fieldContiner 上方。

关于如何解决这个问题的任何想法?任何解决方法?我已经尝试了几件事,但我很挣扎......我现在无法采取行动来改变这个......而且我肯定需要解决这个问题。

提前致谢

(供参考:在 Sencha 论坛中打开错误:https ://www.sencha.com/forum/showthread.php?311212-Fieldcontainer-incorrectly-displays-in-toolbar-with-label-aligned-top )

4

2 回答 2

0

确实看起来像错误,但有一种非常简单的方法可以使这项工作 - 只需设置minHeight: 65到您的 url 字段。

小提琴:https ://fiddle.sencha.com/#fiddle/1caa

于 2016-06-20T06:33:56.750 回答
0

我很确定我找到了答案。build src 和 doc 不匹配!

如果您签入文件的构建源,src/layout/component/field/FieldContainer.js您会注意到它与文档不对应(尤其是缺少某些方法,例如calculateOwnerHeightFromContentHeight)。

注意:这已在 ExtJs 6.2.0 中修复

建议覆盖以解决此问题:

/**
 * Override to fix componentLayout wrong calculation of height when labelAlign='top'
 *
 * See post forum:
 * {@link https://www.sencha.com/forum/showthread.php?311212-Fieldcontainer-incorrectly-displays-in-toolbar-with-label-aligned-top}
 */
Ext.define('MyApp.overrides.layout.component.field.FieldContainer', {
    override: 'Ext.layout.component.field.FieldContainer',
    compatibility: [
        '6.0.0',
        '6.0.1',
        '6.0.2'
    ],

    /* Begin Definitions */

    calculateOwnerHeightFromContentHeight: function(ownerContext, contentHeight) {
        var h = this.callSuper([ownerContext, contentHeight]);
        return h + this.getHeightAdjustment();
    },

    calculateOwnerWidthFromContentWidth: function(ownerContext, contentWidth) {
        var w = this.callSuper([ownerContext, contentWidth]);
        return w + this.getWidthAdjustment();
    },

    measureContentHeight: function(ownerContext) {
        // since we are measuring the outer el, we have to wait for whatever is in our
        // container to be flushed to the DOM... especially for things like box layouts
        // that size the innerCt since that is all that will contribute to our size!
        return ownerContext.hasDomProp('containerLayoutDone') ? this.callSuper([ownerContext]) : NaN;
    },

    measureContentWidth: function(ownerContext) {
        // see measureContentHeight
        return ownerContext.hasDomProp('containerLayoutDone') ? this.callSuper([ownerContext]) : NaN;
    },

    publishInnerHeight: function(ownerContext, height) {
        height -= this.getHeightAdjustment();
        ownerContext.containerElContext.setHeight(height);
    },


    publishInnerWidth: function(ownerContext, width) {
        width -= this.getWidthAdjustment();
        ownerContext.containerElContext.setWidth(width);
    },

    privates: {
        getHeightAdjustment: function() {
            var owner = this.owner,
                h = 0;

            if (owner.labelAlign === 'top' && owner.hasVisibleLabel()) {
                h += owner.labelEl.getHeight();
            }

            if (owner.msgTarget === 'under' && owner.hasActiveError()) {
                h += owner.errorWrapEl.getHeight();
            }

            return h + owner.bodyEl.getPadding('tb');
        },

        getWidthAdjustment: function() {
            var owner = this.owner,
                w = 0;

            if (owner.labelAlign !== 'top' && owner.hasVisibleLabel()) {
                w += (owner.labelWidth + (owner.labelPad || 0));
            }

            if (owner.msgTarget === 'side' && owner.hasActiveError()) {
                w += owner.errorWrapEl.getWidth();
            }

            return w + owner.bodyEl.getPadding('lr');
        }
    }
});
于 2016-06-21T07:43:26.310 回答