I have a regular radWindow used for data entry. I need to run a data verification check when the window is closed to validate the data (that will do an ajax callback to the server). If the close button is clicked, I need to run the validation check and abort the close request if necessary (prevent the window from closing).
Is this possible?
Alternatively, is is possible to modify the radWindow's title bar to add a custom button (design or runtime)?.
Best Regards,
Etienne
Is this possible?
Alternatively, is is possible to modify the radWindow's title bar to add a custom button (design or runtime)?.
Best Regards,
Etienne
3 Answers, 1 is accepted
0
EM
Top achievements
Rank 1
answered on 19 Apr 2008, 11:55 AM
Hi again,
I think I have the answer for point #2 here for a custom button. http://www.telerik.com/community/forums/thread/b311D-bcbmbt.aspx
Still wondering if the behavior of the default close button can be altered to prevent the window from closing based on a return value.
Best regards,
Etienne
I think I have the answer for point #2 here for a custom button. http://www.telerik.com/community/forums/thread/b311D-bcbmbt.aspx
Still wondering if the behavior of the default close button can be altered to prevent the window from closing based on a return value.
Best regards,
Etienne
0
Hi,
Unfortunately, the behavior of the default close button cannot be easily changed.
Does the data verification happen on the parent page or inside the page in the RadWindow? If it happens in the parent page then you can try overriding the default window close method and add your own code.
For example, put the following code in your page just before the window declaration:
This code overrides the close() window method which is called when you click the close button.
Sincerely,
Lini
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Unfortunately, the behavior of the default close button cannot be easily changed.
Does the data verification happen on the parent page or inside the page in the RadWindow? If it happens in the parent page then you can try overriding the default window close method and add your own code.
For example, put the following code in your page just before the window declaration:
| <script type="text/javascript"> |
| Telerik.Web.UI.RadWindow.prototype.oldClose = Telerik.Web.UI.RadWindow.prototype.close; |
| Telerik.Web.UI.RadWindow.prototype.close = function(callBackFnArg) |
| { |
| //your code goes here |
| alert("closing"); |
| //call old close method |
| this.oldClose(callBackFnArg); |
| }; |
| </script> |
| <telerik:RadWindow id="yourWindow" runat="server" ... |
This code overrides the close() window method which is called when you click the close button.
Sincerely,
Lini
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
EM
Top achievements
Rank 1
answered on 23 Apr 2008, 01:18 PM
Thanks for the reply.
Here's the workaround I ended up using. The radWindow has a single close button in its toolbar (the code can be modified to handle multiple buttons, in this case, a single button is expected). Using the OnClientShow event client side, the function OnClientShow() replaces the button dynamically using DOM. This technique is shown in the print button example (link referenced above). The replacement button does a callback client-side, and this callback can optionally close the window if necessary. The validation code can be done server side, or client side, and evaluated in the callback function called when the button is clicked - CloseWindowCallbackFunction in this example. The callback can simply call the Close() on the active window to close it, if that's the desired outcome.
Here's the routine that does the trick:
Here's the workaround I ended up using. The radWindow has a single close button in its toolbar (the code can be modified to handle multiple buttons, in this case, a single button is expected). Using the OnClientShow event client side, the function OnClientShow() replaces the button dynamically using DOM. This technique is shown in the print button example (link referenced above). The replacement button does a callback client-side, and this callback can optionally close the window if necessary. The validation code can be done server side, or client side, and evaluated in the callback function called when the button is clicked - CloseWindowCallbackFunction in this example. The callback can simply call the Close() on the active window to close it, if that's the desired outcome.
Here's the routine that does the trick:
| // custom close button client show event |
| function OnClientShow(radWindow) |
| { |
| var oTitle = radWindow.GetTitlebar(); |
| var oParent = oTitle.parentNode; |
| var oUL = oParent.getElementsByTagName('UL'); |
| var oLI = oUL[0].getElementsByTagName('LI'); |
| var newLI = oLI[0].cloneNode(true); |
| var newA = newLI.getElementsByTagName('a'); |
| //newA[0].className = "custombutton"; |
| newA[0].style.background = "url(test.gif) no-repeat"; |
| newA[0].title = "Close"; |
| newA[0].lastChild.innerHTML = "Close"; |
| newA[0].onmousedown = CloseWindowCallbackFunction; |
| oUL[0].insertBefore(newLI, oLI[0]); |
| // remove the default close button |
| oLI = oUL[0].getElementsByTagName('LI'); |
| oUL[0].removeChild(oLI[1]); |
| } |