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

Close on Click

2 Answers 131 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Robert Bross
Top achievements
Rank 1
Robert Bross asked on 07 Jul 2008, 04:08 PM
I am using a RADMenu that is inside of a RADWindow. What I want is to have a print menu option that would print the contents of the RADWindow. What is happening though is that the Menu gets included on the printout because it isnt closing when I click the print menu item. I tried using the close method of the menu but that isnt working. What do I need to do to accomplish this?

Thanks!

========== Parent Page ======================
<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<html><body><form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
        <telerik:RadWindow ID="RadWindow1" runat="server" NavigateUrl="TestPrintMenu_SubPage.aspx" VisibleOnPageLoad=true></telerik:RadWindow>
</form></body></html>


=========== Sub Page with Menu ================

<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<html>
<script type="text/javascript">
    function printWindow(){
        var menu = $find("mainMenu");
        menu.close();
        window.print();}
</script>
<body><form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
    <telerik:RadMenu ID="mainMenu" runat="server" Skin="Vista" ClickToOpen="True">
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                <Items>
                    <telerik:RadMenuItem runat="server" Text="File">
                        <Items>
                            <telerik:RadMenuItem runat="server" NavigateUrl="javascript: printWindow();" Text="Print"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" IsSeparator="True" Text="-"></telerik:RadMenuItem>
                            <telerik:RadMenuItem runat="server" Text="Close"></telerik:RadMenuItem>
                        </Items>
                    </telerik:RadMenuItem>
                </Items>
    </telerik:RadMenu>
</form></body></html>

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 08 Jul 2008, 02:34 PM
Hi Robert,

RadMenu's close() method will close the expanded item, but it will not hide the menu. To achieve the desired result, I suggest the following solution:

<script type="text/javascript">  
    function printWindow(){  
        var menu = $find("mainMenu");             
        menu.close();         
        var menuDivElement = $get("mainMenu");     
        menuDivElement.style.display = "none";  
        //setTimeout is used to fix a problem with Firefox  
        setTimeout('javascript:window.print()', 500);  
        }  
</script> 


Kind regards,
Peter
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Robert Bross
Top achievements
Rank 1
answered on 08 Jul 2008, 02:58 PM

Thanks for the help. This didnt do exactly what I wanted it to do, but pointed me in the right direction. The code sample below actually hides the entire menu which is not what I need. I needed it to just "Collapse" the file menu. So, expanding upon the code sample provided, I am using that to call another function which prints the window and then reshows the menu. It works good.

Thanks for your help!

=========== Updated Code Sample ==================

function

printWindow(){

var menu = $find("mainMenu");
menu.close();

var menuDivElement = $get("mainMenu");
menuDivElement.style.display =
"none";

//setTimeout is used to fix a problem with Firefox
setTimeout('actualPrintWindow()', 10);
}

function actualPrintWindow(){
window.print();

var menuDivElement = $get("mainMenu");
menuDivElement.style.display =
"block";
}

Tags
Menu
Asked by
Robert Bross
Top achievements
Rank 1
Answers by
Peter
Telerik team
Robert Bross
Top achievements
Rank 1
Share this question
or