- 问题现象多说无益,有图有真象:)
- 详细代码可以看, ExtJS 包中的例子:/examples/form/dynamic.html
Example: Form 1 - Very Simple - Fixed:请去掉logger.info这一行,这个logger是我自己定义的仿造日志货
if (Ext.versions.extjs.getMajor() == 4) { Ext.Loader.require('Ext.layout.component.field.Field', function() { logger.info('修复form.Field在msgTarget=side时的width显示变化的bug'); Ext.layout.component.field.Field.prototype.errorStrategies.side.getErrorElWidth = function(owner) { if (owner.autoFitErrors && owner.hasActiveError()) return owner.errorEl.getWidth(); if (!this.errorElWidth) { var errorEl = owner.errorEl, display = errorEl.getStyle('display'); if (display == 'none') errorEl.setDisplayed(true); this.errorElWidth = errorEl.getWidth(); if (display == 'none') errorEl.setDisplayed(false); } return this.errorElWidth; }; Ext.layout.component.field.Field.prototype.errorStrategies.side.prepare = Ext.Function.createSequence( Ext.layout.component.field.Field.prototype.errorStrategies.side.prepare, function(owner, info) { if (info.autoWidth) info.width += this.getErrorElWidth(owner); } ); Ext.layout.component.field.Field.prototype.errorStrategies.side.adjustHorizInsets = function(owner, info) { info.insets.right += this.getErrorElWidth(owner); }; }); }