This is a migrated thread and some comments may be shown as answers.

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

1 Answer 137 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Phuc
Top achievements
Rank 1
Phuc asked on 06 Nov 2015, 08:59 AM

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

I have a and it displays 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 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();
    }

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 06 Nov 2015, 11:49 AM

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
Tags
General Discussions
Asked by
Phuc
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or