Fieldcontainer错误地显示在工具栏中,标签对齐顶部

时间:2016-06-16 10:23:29

标签: extjs extjs6 extjs6-classic

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

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

有关如何解决此问题的任何想法?任何解决方法? 我已经尝试了几种东西,但我正在努力......我现在不能在哪里采取行动来改变这种情况...... 我肯定需要解决这个问题。

提前致谢

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

2 个答案:

答案 0 :(得分:0)

确实看起来像错误,但有很简单的方法可以让它工作 - 只需将public function dashboard(){ if(Auth::check()){ return View::make('dashboard'); }else{ return "Not logged in"; } } 设置为您的网址字段。

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

答案 1 :(得分: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');
        }
    }
});