我有一個Ext.form.Panel
裏面Ext.window
。窗體高度大於窗口高度,所以我在窗口上有垂直滾動。避免Ext.form驗證滾動到頂部
在窗體字段驗證(在validitychange
事件)上滾動到頂部。
如何避免此行爲?
我有一個Ext.form.Panel
裏面Ext.window
。窗體高度大於窗口高度,所以我在窗口上有垂直滾動。避免Ext.form驗證滾動到頂部
在窗體字段驗證(在validitychange
事件)上滾動到頂部。
如何避免此行爲?
我有同樣的問題:(
我做了一個令人毛骨悚然的解決方法(它的工作原理到80%),有時它仍然跳轉到頂部。 你應該知道,我有一個窗口的「佈局form''如果你有一個窗口(例如)'x'的'form'的'fit'的佈局 - 你可能需要稍微改變一下代碼 例如行el.child(「。的X-Window體」,FASLE)是行不通的。
init: function() {
this.control({
...
/** My Ext.window.Window is called reservationwindow **/
'reservationwindow': {
afterrender: function(comp) {
// comp is this Ext.Component == wrapper
var el = comp.getEl();
//extjs adds the scrollbar to the body element...
var elForm = el.child(".x-window-body", false);
// or el.child(".x-panel-body", false);
//we are listinig to the scroll-event now
this.myFormEl = elForm;
this.safeScroll = {top:0, left:0};
elForm.on('scroll', function() {
console.log("save");
this.safeScroll = this.myFormEl.getScroll();
}, this);
elForm.on('click', function() {
var resWin = this.getResWin();
resWin.scrollBy(0,this.safeScroll.top,false);
console.log("reset");
}, this);
elForm.on('keyup', function() {
var resWin = this.getResWin();
resWin.scrollBy(0, this.safeScroll.top, false);
console.log("reset");
}, this);
}
正如你所看到的,我聽滾動事件並安全並重置滾動條。有時(特別是如果你在文本框中寫得很快),事件將以不同的順序出現,頁面仍然會跳轉到頂部。有時你也會看到它閃爍(如果它需要太長時間才能恢復到原始位置)。
所以....正如我所說,它是一個令人毛骨悚然的解決方法。 如果您找到更好的解決方案,請讓我知道。
編輯
我也想通了,認爲生長在一個textareafield選項是麻煩製造者之一。
{
id: this.id + '-details',
xtype: 'textareafield',
// grow: true, now it isn't jumping
name: 'message',
fieldLabel: 'Zusätzliche Informationen',
labelAlign: 'top',
renderder: 'htmlEncode',
disabled: isDisabled,
anchor: '100%'
}
我想弄清楚,爲什麼我的一種形式做滾動和其他沒有。原來,我忘了明確指定佈局管理器,並且默認佈局管理器(錨點)在有效性更改上滾動到頂部,而vbox
佈局沒有。雖然一切看起來完全相同(與align: 'stretch'
的vbox),但它顯示或隱藏錯誤時的行爲不同。
謝謝,它適用於我。只需將佈局更改爲'vbox'即可。 – wengeezhang 2015-11-10 07:32:13