Can I get a value returned from Close handler of a RadWindow?

2 posts, 0 answers
  1. Phuc
    Phuc avatar
    1 posts
    Member since:
    Oct 2015

    Posted 06 Nov 2015 Link to this post

    Sorry guys if this is a dump question, but I am a newbie in programming language and this is the first time I use RadWindow.

    I have a radwindow and it displays under a dialog. As you know, after closing this dialog, its ​Close handler function will be hit. In there, I return a boolean value. 
    And my problem is that I want to get the return value directly from the Close handler without using any global flags.

     

    Please reference the snippet code below to get more detail.

    Function used for showing the dialog:

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

    And its Close handle function. As you see, I want to return true|false value in this handler.  

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

     OK, and is there any way I can receive the true|false value from the handler like this:

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

     

     

     

    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);
            wnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Resize);
            wnd.show();
            wnd.center();
        }

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 06 Nov 2015 Link to this post

    Hello,

    Here is how this works:

    1. The developer passes an argument to the close() method of the RadWindow
    2. RadWindow passes that object to its OnClientClose handler
    3. The stack ends. Thus local variables like the arguments are disposed.

    If you want that data in another function, you should call that function from the OnClientClose handler.

    The alternative I can offer is to simply use a custom field in the client-side object of the RadWindow, but for that you will need to disable the DestroyOnClose feature and it would still act as a global variable.

    One other option I can put forward is using tools like the browser's local storage but whether this is possible depends on your architecture and whether the browser supports that.

    Regards,

    Marin Bratanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top