简体   繁体   English

win.close()还会关闭ExtJS中的消息框

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

I have a textbox. 我有一个文本框。 As soon as user types something, I open a window and show the data in the window. 用户键入内容后,我将打开一个窗口并在该窗口中显示数据。 If no result is found, I want to close this window and then show a message box. 如果未找到结果,我想关闭此窗口,然后显示一个消息框。 Please see below image for more information. 请参阅下图以获取更多信息。 在此处输入图片说明

On the load event of the store I have written following code. 关于商店的加载事件,我编写了以下代码。

'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);
                }
            }
        }

Now to close the search result window, I have changed the code to: 现在关闭搜索结果窗口,我将代码更改为:

'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);
                }
            }
        }

But when this code executes, it also closes message box (along with search window). 但是,当执行此代码时,它也会关闭消息框(以及搜索窗口)。 I just want to close the search window. 我只想关闭搜索窗口。

Please helo 请喂

First is, that the messagebox ( as explained by Evan Trimboli ) is no child of the window. 首先,该消息框(如Evan Trimboli所述)不是该窗口的子级。

I've testes this behavior on my local extjs project( creating an Ext.Window, and then creating an messagebox ). 我已经在本地extjs项目中测试了此行为(创建一个Ext.Window,然后创建一个messagebox)。 Heres some code 继承人一些代码

    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);
},

using this code, extjs will close the window and not the messagebox. 使用此代码,extjs将关闭窗口,而不是消息框。

using 使用

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

will close the messagebox. 将关闭消息框。

have you already debugged how often your load event is triggert? 您是否已经调试了触发加载事件的频率?

Maybe its triggerd twice, first getActive returns the messagebox, second trigger, returns the window? 也许它触发了两次,第一个getActive返回消息框,第二个触发,返回窗口? both windows are getting closed. 两个窗户都关闭了。

cheers! 干杯!

I don't think that its possible to just close the window while retaining the message box. 我认为在保留消息框的同时关闭窗口是不可能的。 What you can do is once the window is closed, display a new message box with the same text. 您可以做的就是关闭窗口后,显示一个带有相同文本的新消息框。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM