This is a migrated thread and some comments may be shown as answers.
Add Button to RadWindow Title Bar
4 Answers 109 Views
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 16 Mar 2012, 03:42 PM
I'm working with the Telerik RadWindow, and I am writing to ask how best to add a button to the RadWindow Title Bar;

Best regards - Rob

4 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 19 Mar 2012, 05:38 AM
Hello Robert,

Try the following javascript on hooking OnClientShow event of the RadWindow.

JS:
<script type="text/javascript">
function OnClientShow(radWindow)
{
 var TitleBar = radWindow.GetTitlebar();
 var parent = TitleBar.parentNode;
 var oUL = parent.getElementsByTagName('UL')[0];
 if (!(oUL.firstChild.id == "customprintbuttonID"))
 {
   oUL.style.width = "192px";
   var oLI = document.createElement("LI");
   oLI.id = "customprintbuttonID"
   var A = document.createElement("A");
   oLI.appendChild(A);
   A.className = "customprintbutton";
   A.href = "javascript:void(0)";
   A.title = "Print Content";
   oUL.insertBefore(oLI, oUL.firstChild);
   radWindow._updateTitleWidth();
 }
}

Thanks,
Princy.
0
Robert
Top achievements
Rank 1
answered on 19 Mar 2012, 01:41 PM
Thank you for the response, and the code to place the button on the Title Bar works great;

An additional question -

Is it possible to place a customized button, which reads "Return to Menu" as an example;

I am hoping to utilize this button to close the RadWindow - I already have the necessary JavaScript;

Thanks in advance for any insight;
0
Accepted
Princy
Top achievements
Rank 1
answered on 20 Mar 2012, 10:22 AM
Hello Robert,

Try the following JavaScript to close the RadWindow on Clicking the Button.
JS:
<script type="text/javascript">
 function OnClientShow(radWindow)
  {
   var TitleBar = radWindow.GetTitlebar();
   var parent = TitleBar.parentNode;
   var oUL = parent.getElementsByTagName('UL')[0];
   if (!(oUL.firstChild.id == "customprintbuttonID"))
    {
     oUL.style.width = "192px";
     var oLI = document.createElement("LI");
     oLI.id = "customprintbuttonID"
     var A = document.createElement("A");
     oLI.appendChild(A);
     A.className = "customprintbutton";
     A.href = "javascript:void(0)";
     A.title = "Close";
     A.onmousedown = closewindow;
     oUL.insertBefore(oLI, oUL.firstChild);
     radWindow._updateTitleWidth();
    }
  }
 function closewindow(e)
  {
   var oManager = GetRadWindowManager();
   var oWnd = oManager.GetWindowByName("RadWindow1");
   oWnd.Close();
   return $telerik.cancelRawEvent(e);
  }
</script>

Thanks,
Princy.
0
Accepted
rdmptn
Top achievements
Rank 1
answered on 20 Mar 2012, 12:11 PM
I believe you'd rather want to change the title property of the custom button to the desired string in the above snippet. Or you could just use the built-in Close button (with the [x]) and change its tooltip to the desired string via the localization options the RadWindow provides (http://www.telerik.com/help/aspnet-ajax/radwindow-localization.html).
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Robert
Top achievements
Rank 1
rdmptn
Top achievements
Rank 1
Share this question
or