Rad window (Javascript)


Opening the radwindow from the parent page, and if we have entered any data in any field in the radwindow,user need to be notified.



 function OpenWindow() {
            radopen("Javascript.aspx", "RadWindow2");
            ConfirmClose("RadWindow2");
        }


How to call this function in button click


<div>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
        </telerik:RadWindowManager>
        <input type="button" onclick="OpenWindow()" value="Open Window" />
    </div>


  function ConfirmClose(WinName) {
            
            var oManager = GetRadWindowManager();
            oWnd = oManager.GetWindowByName(WinName);
           if (i==0)
               oWnd.add_beforeClose(onBeforeClose);
           i++;
        }

checking whether there is any data in textboxes or Grid,If so user is asked, whether he really want to close the window.We use confirmation boxes,

A confirmation box will pop up much like an alert box, but will allow the viewer to press an “OK” or “Cancel” button. Here is the basic command for creating a confirmation box:

confirm(“Text or question you want to use”);

The confirmation box will return a value of true or false, so this is what we must use to make use of the confirmation box.


     var where_to = confirm("Do u Really Wanna Close?");
                

Now, you can use the where_to variable to send the user to one page or another, depending on the value the confirmation box returned. You can do this with an if/else block:


 if (where_to == false) {

                    args.set_cancel(true);

                }
                else {
                    args.set_cancel(false);
                }
 

In this case, if the viewer hits the “OK” button, Radwindow will get closed If the viewer hits the cancel button, window remains opened.


 function onBeforeClose(oWnd, args) {

            var txtFirstName = oWnd.GetContentFrame().contentWindow.document.getElementById('txtFirstName').value;
            var txtLastName = oWnd.GetContentFrame().contentWindow.document.getElementById('txtLastName').value;
            var grid = oWnd.GetContentFrame().contentWindow.$find('rdCheck')
            var masterTable = grid.get_masterTableView();
           
            if (txtFirstName != "" || txtLastName != "" || masterTable != null) {
              
                var where_to = confirm("Do u Really Wanna Close?");
                if (where_to == false) {

                    args.set_cancel(true);
                    

                }

                else {

                    args.set_cancel(false);
                    
                }
                              }

            }
Advertisements

2 responses to this post.

  1. Hi I am having a requirement where I need to call a radwindow on cancel event in a radgrid can you help me

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: