我有一个numberfield
我将maxLength
属性设置为enforceMaxLength
。因此,该字段不会接受maxLength
上的值,到目前为止还不错。
我想根据其他组件值更改此maxLength
属性。我尝试了几种方法但没有成功(它设置了值但没有工作)。
问题是,如何在渲染后更改组件的初始属性?
{
xtype: 'combobox',
fieldLabel: 'PROMOSYON TİPİ',
name: 'PROMO_TYPE',
id: 'promo_type',
displayField: 'PROMO_TYPE_NAME',
valueField: 'PROMO_TYPE_VALUE',
store: promoType,
queryMode: 'local',
inputWidth: 250,
labelWidth: '280px',
margin: '0 0 15 0',
listeners: {
change: function(cb,nv) {
if (nv != 0 || nv != 2) {
var pd = Ext.getCmp('promo_disc');
Ext.apply(pd, {maxLength: 8});
}
}
}
},
{
xtype: 'numberfield',
name: 'PROMO_DISCOUNT',
fieldLabel: 'PROMOSYON İNDİRİMİ',
id: 'promo_disc',
inputWidth: 250,
labelWidth: '280px',
margin: '0 0 15 0',
maxLength: 3,
enforceMaxLength: true,
minValue: 0
}
答案 0 :(得分:0)
根据@forgivenson的想法,我采取了以下方式。
{
xtype: 'combobox',
fieldLabel: 'PROMOSYON TİPİ',
name: 'PROMO_TYPE',
id: 'promo_type',
displayField: 'PROMO_TYPE_NAME',
valueField: 'PROMO_TYPE_VALUE',
store: promoType,
queryMode: 'local',
inputWidth: 250,
labelWidth: '280px',
margin: '0 0 15 0',
listeners: {
change: function(cb,nv) {
if (nv != 0 || nv != 2) {
// promo_disc-inputEl is an ID for <input> element
Ext.get('promo_disc-inputEl').set({maxlength: 8});
}
}
}
},
{
xtype: 'numberfield',
name: 'PROMO_DISCOUNT',
fieldLabel: 'PROMOSYON İNDİRİMİ',
id: 'promo_disc',
inputWidth: 250,
labelWidth: '280px',
margin: '0 0 15 0',
maxLength: 3,
enforceMaxLength: true,
minValue: 0
},