簡體   English   中英

win.close()還會關閉ExtJS中的消息框

[英]win.close() also closes message box in ExtJS

我有一個文本框。 用戶鍵入內容后,我將打開一個窗口並在該窗口中顯示數據。 如果未找到結果,我想關閉此窗口,然后顯示一個消息框。 請參閱下圖以獲取更多信息。 在此處輸入圖片說明

關於商店的加載事件,我編寫了以下代碼。

'load': function (thisStore, records, successful, eOpts) {
            if (successful) {
                if (records == null || typeof records[0] === "undefined") {

                    var msg = 'No records found for the given selection.';
                    MessageWindow.show('Information', msg, Ext.Msg.OK, Ext.Msg.INFO);
                }
            }
        }

現在關閉搜索結果窗口,我將代碼更改為:

'load': function (thisStore, records, successful, eOpts) {
            if (successful) {
                if (records == null || typeof records[0] === "undefined") {
                      var win = Ext.WindowManager.getActive();
                        if (win) {
                            win.close();
                        }
                    var msg = 'No records found for the given selection.';
                    MessageWindow.show('Information', msg, Ext.Msg.OK, Ext.Msg.INFO);
                }
            }
        }

但是,當執行此代碼時,它也會關閉消息框(以及搜索窗口)。 我只想關閉搜索窗口。

請喂

首先,該消息框(如Evan Trimboli所述)不是該窗口的子級。

我已經在本地extjs項目中測試了此行為(創建一個Ext.Window,然后創建一個messagebox)。 繼承人一些代碼

    openWindow: function() {
    this.initWindow();
    this.window.doLayout();
    this.window.show();

    Ext.MessageBox.alert( translate('error', 'general'), 'tag' );
    window.setTimeout(function() {                 
        BlueFork.Taskstatus.Creation.window.close();
        BlueFork.Taskstatus.Creation.window.destroy();
    }, 5000);
},

使用此代碼,extjs將關閉窗口,而不是消息框。

使用

var win = Ext.WindowManager.getActive();
win.close();

將關閉消息框。

您是否已經調試了觸發加載事件的頻率?

也許它觸發了兩次,第一個getActive返回消息框,第二個觸發,返回窗口? 兩個窗戶都關閉了。

干杯!

我認為在保留消息框的同時關閉窗口是不可能的。 您可以做的就是關閉窗口后,顯示一個帶有相同文本的新消息框。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM