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

Close Rad window when press outside it

6 Answers 205 Views
Window
This is a migrated thread and some comments may be shown as answers.
ahmed
Top achievements
Rank 1
ahmed asked on 08 Jan 2014, 06:51 AM
hello

is that possible to Close Rad window when press outside it

Best Regards

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 08 Jan 2014, 08:56 AM
Hi ahmed,

Please have a look into the following code snippet to close the RadWindow by clicking outside of it.

ASPX:
<telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true">
</telerik:RadWindow>

JavaScript:
<script type="text/javascript">
    function pageLoad() {
        $addHandler(document, "click", onClickHandler);
        lastOpenedWindow = $find("<%=RadWindow1.ClientID %>");
    }
    var lastOpenedWindow;
    var clickedtd;
    function onClickHandler(e) {
        var targedNodeName = e.target;
        if (lastOpenedWindow && (targedNodeName != clickedtd)) {
            if ($telerik.isMouseOverElementEx(lastOpenedWindow.get_popupElement(), e)) return;
            lastOpenedWindow.close();
            lastOpenedWindow = null;
            clickedtd = null;
        }
    }
</script>

Thanks,
Shinu.
0
ahmed
Top achievements
Rank 1
answered on 08 Jan 2014, 01:13 PM
thank you it work
but only one time when page load after that close when active rad window again not hide
0
Shinu
Top achievements
Rank 2
answered on 09 Jan 2014, 03:50 AM
Hi ahmed,

Unfortunately I couldn't replicate the issue at my end. Please have a look into the sample code snippet which works fine at my end.

ASPX:
<telerik:RadButton ID="RadButton1" runat="server" Text="Show RadWindow" OnClick="RadButton1_Click">
</telerik:RadButton>
<telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="false">
</telerik:RadWindow>

C#:
protected void RadButton1_Click(object sender, EventArgs e)
{
    RadWindow1.VisibleOnPageLoad = true;
}

JavaScript:
<script type="text/javascript">
    function pageLoad() {
        $addHandler(document, "click", onClickHandler);
        lastOpenedWindow = $find("<%=RadWindow1.ClientID %>");
    }
    var lastOpenedWindow;
    function onClickHandler(e) {
        if (lastOpenedWindow.IsVisible()) {
            lastOpenedWindow.close();
        }
    }
</script>

Hope this will helps you.
Thanks,
Shinu.
0
ahmed
Top achievements
Rank 1
answered on 09 Jan 2014, 08:18 AM
thank you its work prefect
i have small problem in toggle mode
the rad menu always in top like attached picture
0
Shinu
Top achievements
Rank 2
answered on 10 Jan 2014, 04:23 AM
Hi ahmed.

Please have a look into the sample code snippet which works fine at my end.

ASPX:
<telerik:RadMenu ID="RadMenu1" runat="server" EnableRoundedCorners="true" EnableShadows="true"
    Skin="Default" EnableTextHTMLEncoding="true" ShowToggleHandle="true">
    <Items>
        <telerik:RadMenuItem Text="Products">
            <Items>
                <telerik:RadMenuItem Text="ASP.NET AJAX Controls" />
                <telerik:RadMenuItem Text="WinForms Controls" />
            </Items>
        </telerik:RadMenuItem>
        <telerik:RadMenuItem Text="Consulting">
            <Items>
                <telerik:RadMenuItem Text="On-site Training" />
                <telerik:RadMenuItem Text="Consulting Express" />
            </Items>
        </telerik:RadMenuItem>
        <telerik:RadMenuItem Text="Purchase">
            <Items>
                <telerik:RadMenuItem Text="Buy Now" />
                <telerik:RadMenuItem Text="Renewals & Upgrades" />
            </Items>
        </telerik:RadMenuItem>
    </Items>
</telerik:RadMenu>

Please provide your full code with CSS if it doesn't help.
Thanks,
Shinu.
0
ahmed
Top achievements
Rank 1
answered on 12 Jan 2014, 06:43 AM
not work
and i don't made to radmenu any classes in CSS file
Tags
Window
Asked by
ahmed
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
ahmed
Top achievements
Rank 1
Share this question
or