目前我遇到了將焦點設置爲extjs textfield的問題。當表單顯示時,我想將焦點設置爲名字文本框,並嘗試在函數focus()中使用構建,但仍無法使其工作。 我很高興看到您的建議。將焦點集中在Extjs textfield
var simple = new Ext.FormPanel({
labelWidth: 75,
url:'save-form.php',
frame:true,
title: 'Simple Form',
bodyStyle:'padding:5px 5px 0',
width: 350,
defaults: {width: 230},
defaultType: 'textfield',
items: [{
fieldLabel: 'First Name',
name: 'first',
id: 'first_name',
allowBlank:false
},{
fieldLabel: 'Last Name',
name: 'last'
},{
fieldLabel: 'Company',
name: 'company'
}, {
fieldLabel: 'Email',
name: 'email',
vtype:'email'
}, new Ext.form.TimeField({
fieldLabel: 'Time',
name: 'time',
minValue: '8:00am',
maxValue: '6:00pm'
})
],
buttons: [{
text: 'Save'
},{
text: 'Cancel'
}]
});
simple.render(document.body);
哪裏是試圖設置焦點的代碼? – czarchaic
即使延遲了ExtJS 4.2,我也無法使用它。我想這需要在一些回調中完成,但我找不到哪一個。我已經嘗試了視圖上的「渲染器」事件偵聽器,但這也沒有奏效。 – MacGyver
另請參見[在剛剛創建的窗口中爲文本輸入設置焦點](https://stackoverflow.com/questions/11092833/set-focus-for-text-input-in-just-created-window) – Vadzim