我是 Extjs 的新手。我有字段的形式。我需要为特定领域设置重点。这是我正在使用的代码。
var priceTFLme = {
xtype: 'numberfield',
id:'priceLme',
fieldLabel: 'Price',
name: 'price',
value: bidOffer,
minValue: 0,
maxValue: 100,
allowDecimals: true,
decimalPrecision: 3,
step: 0.005,
vtype: 'natural'
};
var quantityTFLme = {
xtype: 'textfield',
id: 'quantityLme',
fieldLabel: 'Quantity',
value: '',
editable: true,
hasFocus: true,
vtype: 'natural',
listeners: {
afterrender: function(field) {
field.focus(false, 1000);
}
}
};
var formLME = new Ext.FormPanel({
labelWidth: 85,
frame:true,
id:'lmeHeaders',
bodyStyle:'padding:10px 10px 0',
defaults: {width: 225},
defaultType: 'textfield',
items: [quantityTFLme, priceTFLme ],
buttons: [{
id:'buyIdLME',
handler: function () {
}
}, {
id:'sellIdLME',
handler: function () {
}
}]
});
var winLme = Ext.widget('window', {
closeAction: 'close',
layout: 'fit',
resizable: false,
constrain: true,
modal: true,
items: formLME
});
function requestForLMEPrice() {
if (!winLme.rendered) {
winLme.render(Ext.getBody());
}
winLme.center();
winLme.show();
}
我要关注的领域有数量。但是我无法集中注意力。
有人可以帮忙吗?
此外,我尝试使用 Ext.getCmp('quantityTFLme').focus(false, 200);
最佳答案
尝试 defer在触发焦点之前,
示例代码:
afterrender: function(field) {
Ext.defer(function() {
field.focus(true, 100);
}, 1);
}
关于javascript - 无法为 Extjs 文本字段设置焦点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22803204/