How to add Close Command on Client Side?

5 posts, 0 answers
  1. Alec
    Alec avatar
    43 posts
    Member since:
    Mar 2009

    Posted 02 Sep 2009 Link to this post

    Say I drag a dock to a zone. How to add a close command to the dock on client side?
  2. Mr. Plinko
    Mr. Plinko avatar
    56 posts
    Member since:
    Jul 2009

    Posted 02 Sep 2009 Link to this post

    Are you wanting to add a close command when the dock is in a zone, but not have it be available when it isn't?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alec
    Alec avatar
    43 posts
    Member since:
    Mar 2009

    Posted 02 Sep 2009 Link to this post

    Yes. Like it's created without any commands. but when dragged and dropped onto a zone, the close command appears.
  5. Vyrban
    Vyrban avatar
    31 posts
    Member since:
    Nov 2008

    Posted 03 Sep 2009 Link to this post

    Ok, why don't you add it initially and when your dock / undock  the RadDock from the zone just hide / show the command?
    There is my proposition:
    <body> 
        <script type="text/javascript"
            function DragEnd(dock, args) { 
                var commandClose = dock.get_commands().Close; 
                var dockdockZoneId = dock.get_dockZoneID(); 
                if (dockZoneId == "") { 
                    commandClose.set_visible(false); 
                } 
                else { 
                    commandClose.set_visible(true); 
                 } 
            } 
        </script> 
        <form id="form1" runat="server"
           <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> 
        <div> 
            <telerik:RadDockZone ID="RadDockZone1" runat="server" Width="300px"
                <telerik:RadDock ID="RadDock1" runat="server" DefaultCommands="Close"  
                Width="290px" OnClientDragEnd="DragEnd"></telerik:RadDock> 
            </telerik:RadDockZone> 
        </div> 
        </form> 
    </body> 

  6. Mr. Plinko
    Mr. Plinko avatar
    56 posts
    Member since:
    Jul 2009

    Posted 03 Sep 2009 Link to this post

    Vyrban, you read my mind! I decided to do OnClientDockPositionChanged rather than OnClientDragEnd. Also, I had the dock be floating to start. Same Same but Different. :)

    <script 
                type="text/javascript"
                function NoCloseFloats(dock) { 
                    var id = dock.get_dockZoneID(); 
                    if (id == "") { 
                        dock.get_commands().Close.set_visible(false); 
                    } 
                    else { 
                        dock.get_commands().Close.set_visible(true); 
                    } 
                } 
            </script> 
     
            <telerik:RadDockLayout 
                ID="RadDockLayout1" 
                runat="server"
                <telerik:RadDockZone 
                    ID="RadDockZone1" 
                    runat="server" Width="300px"
                </telerik:RadDockZone> 
            </telerik:RadDockLayout> 
            <telerik:RadDock 
                ID="RadDock1" 
                runat="server" 
                OnClientDockPositionChanged="NoCloseFloats" OnClientInitialize="NoCloseFloats"
                <ContentTemplate> 
                    ABC 
                </ContentTemplate> 
            </telerik:RadDock> 

    This makes it so when you start out with the dock floating, there is no [X] close, but when it is docked the [X] appears, then disappears when taken off a dock.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017