像这样的数字领域
xtype : 'numberfield',
fieldLabel : 'this is a label',
id : 'id',
name : 'id',
width : 50,
labelStyle : 'width:300px',
minValue : 1,
hideTrigger : true,
allowNegative : false,
maxValue : 7,
decimalPrecision : 1,
allowPureDecimal : true,
editable : true,
allowBlank : false
接受数字1,1.1,3.5 ...... 7
但我也需要接受0。在extjs中存在一个属性,例如异常或允许输入0的东西以及建立的最小值和最大值?
如果有人能指导我,我将不胜感激
谢谢你的时间!
我不认为有这样做的属性,但您可以注册一个更改侦听器并检查newValue参数是否介于0和1之间。如果是这样,请将numberfield的值设置为零。
listeners: {
change: function (component, newValue, oldValue) {
if (newValue > 0 && newValue < 1)
component.setValue(0);
}
}
删除minValue
和maxValue
配置,然后使用validator配置设置自定义验证功能。
xtype: 'numberfield',
fieldLabel: 'this is a label',
id: 'id',
name: 'id',
hideTrigger: true,
allowNegative: false,
decimalPrecision: 1,
allowPureDecimal: true,
editable: true,
allowBlank: false,
validator() {
value = this.getValue();
if (value === 0 || (value >= 1 && value <=7)) {
return true;
}
return 'Not valid';
}