DockCloseCommand fires after close?

4 posts, 0 answers
  1. Timothy Faase
    Timothy Faase avatar
    2 posts
    Member since:
    Feb 2008

    Posted 23 Feb 2012 Link to this post

    Hi there,

    I am keen to (confirm('If someone actually wants to delete their dock?'))

    But it seems DockCloseCommand client side command fires after it's been closed??
  2. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 28 Feb 2012 Link to this post

    Hi Timothy,

    Note that the closing of a RadDock control cannot be canceled when its Close command is used. My suggestion is to create custom command with the same functionality as the Close command and then to use client-side script to close the RadDock if confirmed.

    Below is an example of adding DockCommand to the Commands collection of RadDock and attaching a client-side event handler, which implements the custom command logic:

    <!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>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
      
            <script type="text/javascript">
                function ClientCommand(sender, args) {
                    if (args.Command.get_name() == "CustomClose") { // check if this is the custom Close command
                        var closed = confirm("Are you sure?");
                        sender.set_closed(closed); // set_closed method of RadDock client-side object is used to close the control
                        args.set_cancel(!closed); // this method will cancel the server-side event if the RadDock close isn't confirmed, the condition under which you cancel it depends on your custom scenario
                    }
                }
            </script>
      
            <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
                <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="300px" Width="300px">
                    <telerik:RadDock ID="RadDock1" runat="server" Width="300px" OnClientCommand="ClientCommand" Title="RadDock" Text="Content">
                        <Commands>
                            <telerik:DockCommand Name="CustomClose" Text="Close" CssClass="rdClose" /> <%--the custom Close command, it uses the CSS class of Close command--%>
                        </Commands>
                    </telerik:RadDock>
                </telerik:RadDockZone>
            </telerik:RadDockLayout>
        </div>
        </form>
    </body>
    </html>

    Feel free to contact us again if you run into more difficulties.

    Regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Timothy Faase
    Timothy Faase avatar
    2 posts
    Member since:
    Feb 2008

    Posted 28 Feb 2012 Link to this post

    Hi Slav,

    Any clues to why this event doesn't fire? I have tried the above, also including:

    <telerik:DockCommand Name="CustomClose" Text="Close" CssClass="rdClose" OnClientCommand="ClientCommand" /> 

    Could another event be overriding it?
  5. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 02 Mar 2012 Link to this post

    Hi Timothy,

    Please ensure that the handler of the client-side event OnClientCommand is attached correctly.  You can check this help article on the matter.

    I have attached a sample project, demonstrating the suggested approach, so that you can compare it with you actual project and check if there are differences in the setup.

    If you are still unable to resolve the issue, please modify the attached sample so that the described behavior can be reproduced, open a support ticket and send it so that I can examine your scenario locally and suggest an according solution.

    Kind regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top