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

How to add Close Command on Client Side?

4 Answers 96 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Alec
Top achievements
Rank 1
Alec asked on 02 Sep 2009, 05:25 AM
Say I drag a dock to a zone. How to add a close command to the dock on client side?

4 Answers, 1 is accepted

Sort by
0
Mr. Plinko
Top achievements
Rank 1
answered on 02 Sep 2009, 03:05 PM
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?
0
Alec
Top achievements
Rank 1
answered on 03 Sep 2009, 01:30 AM
Yes. Like it's created without any commands. but when dragged and dropped onto a zone, the close command appears.
0
Vyrban
Top achievements
Rank 1
answered on 03 Sep 2009, 12:12 PM
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> 

0
Mr. Plinko
Top achievements
Rank 1
answered on 03 Sep 2009, 03:53 PM
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.
Tags
Dock
Asked by
Alec
Top achievements
Rank 1
Answers by
Mr. Plinko
Top achievements
Rank 1
Alec
Top achievements
Rank 1
Vyrban
Top achievements
Rank 1
Share this question
or