【问题标题】:Can I get a value returned from Close handler of a RadWindow?我可以获得从 RadWindow 的关闭处理程序返回的值吗?
【发布时间】:2015-11-06 09:02:04
【问题描述】:

我有一个 radwindow,它显示在一个对话框下。如您所知,关闭此对话框后,将触发其关闭处理函数。在那里,我返回一个布尔值。 而我的问题是我想直接从 Close 处理程序获取返回值不使用任何全局标志

请参考下面的 sn-p 代码以获取更多详细信息。

用于显示对话框的函数:

function showDialog() {
        var url = "ChildPage.aspx";
        var wnd = window.radopen(url, 'Child Dialog');
        wnd.set_modal(true);
        wnd.setSize(400, 120);
        wnd.set_minHeight(300);
        wnd.set_minWidth(100);
        wnd.set_destroyOnClose(true);
        wnd.set_keepInScreenBounds(true);
        wnd.set_overlay(false);
        wnd.set_visibleStatusbar(false);
        wnd.set_visibleTitlebar(true);
        wnd.add_close(closeChildDialogHandler); //closeChildDialogHandler is Close handler
        wnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Resize);
        wnd.show();
        wnd.center();
    }

及其关闭句柄功能。如您所见,我想在此处理程序中返回 true|false 值。

function closeChildDialogHandler(sender, args) {
        var flag = false;
        var objConfirmSQ = args.get_argument();
        if (objConfirmSQ != null && typeof objConfirmSQ['returnValue'] != "undefined") {
            console.log("objConfirmSQ['returnValue'] = " + objConfirmSQ['returnValue']);
            return true;
        }
        else {
            return false;
        }
    }

好的,有什么方法可以像这样从处理程序接收 true|false 值:

function myFunction(){
  var myVar = closeChildDialogHandler(unknown_param, unknown_param) //Not sure about this
}

【问题讨论】:

    标签: javascript asp.net web telerik radwindow


    【解决方案1】:

    一个抽象的解决方案是:

    回调机制是返回机制的一个很好的替代方案。


    更具体的解决方案:
    1) 声明一个函数。

    childCloseResponseListener = function(myBooleanValue) {
    /*Your handling for the boolean value when it gets here*/
    }
    childCloseResponseListener.bind(this);
    

    2) 从对话框的关闭监听器访问它

    childCloseResponseListener(true);
    

    childCloseResponseListener(false);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-03
      • 1970-01-01
      • 1970-01-01
      • 2021-03-27
      • 2021-08-08
      • 1970-01-01
      相关资源
      最近更新 更多