Loop on client closing 2010.1.309.35

3 posts, 1 answers
  1. Lorenzo Margola
    Lorenzo Margola avatar
    8 posts
    Member since:
    Jan 2008

    Posted 14 Apr 2010 Link to this post

    Hi, I have a strange behavior on my code.
    When I call the set_closed client-side method on a RadDock that has a DockCommand with OnClientCommand event attached, my script enters in a loop cycle.

    Here you are a sample code that illustrates the behavior.
    Just click on ShowHideRadDock1 to replicate the bug.
    Thanks.

    <script type="text/javascript"
     
            function RadDockClientCommand(sender, eventArgs) { 
                alert('RadDockClientCommand'); 
                if (eventArgs.Command.get_name() == "Close") { 
                    var isClosed = sender.get_closed(); 
                    sender.set_closed(!isClosed); 
                } 
            } 
     
            function ShowHideRadDock(controlID) { 
                alert('In ShowHideRadDock'); 
                var dock = $find('RadDock1'); 
                var isClosed = dock.get_closed(); 
                dock.set_closed(!isClosed); 
            } 
             
        </script> 

    <body> 
        <form id="form1" runat="server"
        <telerik:RadScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="true"
             
        </telerik:RadScriptManager> 
     
        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="javascript:ShowHideRadDock('RadDock1');">ShowHideRadDock1</asp:HyperLink> 
        <br /> 
        <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="javascript:ShowHideRadDock('RadDock2');">ShowHideRadDock2</asp:HyperLink> 
        <br /> 
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server"
            <telerik:RadDock ID="RadDock1" runat="server" Skin="Telerik" Width="300px" Left="50px" 
                CloseText="chiudi" BackColor="#a79c00" CssClass="RadDockPostIt"
                <Commands> 
                    <telerik:DockCommand Name="Close" Text="Chiudi" OnClientCommand="RadDockClientCommand" 
                        CssClass="rdClose" /> 
                </Commands> 
             <ContentTemplate> 
                    My Content RadDock1 
                </ContentTemplate> 
            </telerik:RadDock> 
            <telerik:RadDock ID="RadDock2" runat="server" Skin="Telerik" Width="300px" Left="50px" 
                Top="120px" CloseText="chiudi" BackColor="#a79c00"
               <Commands> 
                    <telerik:DockCommand Name="Close" Text="Chiudi" OnClientCommand="RadDockClientCommand" 
                        CssClass="rdClose" /> 
                </Commands> 
                <ContentTemplate> 
                    My Content RadDock2 
                </ContentTemplate> 
            </telerik:RadDock> 
        </telerik:RadDockLayout> 
        </form> 
    </body> 


  2. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 16 Apr 2010 Link to this post

    Hi Lorenzo,

    When creating a custom DockCommand that is used to replace the functionality of a built-in command (like the built-in Close command in your case), you need to specify a different DockCommand Name than the one of the built-in command. So, your command should not be named "Close", but differently, like "CustomClose" for example. After specifying different name the problem disappears. Here is the modified code:

    .aspx
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head id="Head1" runat="server">
        <title></title>
     
        <script type="text/javascript">
     
            function RadDockClientCommand(sender, eventArgs)
            {
                alert('RadDockClientCommand');
                if (eventArgs.Command.get_name() == "CustomClose")
                {
                    var isClosed = sender.get_closed();
                    sender.set_closed(!isClosed);
                }
            }
     
            function ShowHideRadDock(controlID)
            {
                alert('In ShowHideRadDock');
                var dock = $find('RadDock1');
                var isClosed = dock.get_closed();
                dock.set_closed(!isClosed);
            }
              
        </script>
     
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            </Scripts>
        </asp:ScriptManager>
        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="javascript:ShowHideRadDock('RadDock1');">ShowHideRadDock1</asp:HyperLink>
        <br />
        <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="javascript:ShowHideRadDock('RadDock2');">ShowHideRadDock2</asp:HyperLink>
        <br />
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
            <telerik:RadDock ID="RadDock1" runat="server" Skin="Telerik" Width="300px" Left="50px"
                CloseText="chiudi" BackColor="#a79c00" CssClass="RadDockPostIt">
                <Commands>
                    <telerik:DockCommand Name="CustomClose" Text="Chiudi" OnClientCommand="RadDockClientCommand"
                        CssClass="rdClose" />
                </Commands>
                <ContentTemplate>
                    My Content RadDock1
                </ContentTemplate>
            </telerik:RadDock>
            <telerik:RadDock ID="RadDock2" runat="server" Skin="Telerik" Width="300px" Left="50px"
                Top="120px" CloseText="chiudi" BackColor="#a79c00">
                <Commands>
                    <telerik:DockCommand Name="CustomClose" Text="Chiudi" OnClientCommand="RadDockClientCommand"
                        CssClass="rdClose" />
                </Commands>
                <ContentTemplate>
                    My Content RadDock2
                </ContentTemplate>
            </telerik:RadDock>
        </telerik:RadDockLayout>
        </form>
    </body>
    </html>



    Greetings,
    Pero
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Lorenzo Margola
    Lorenzo Margola avatar
    8 posts
    Member since:
    Jan 2008

    Posted 16 Apr 2010 Link to this post

    Thanks now it works.
Back to Top