This is a migrated thread and some comments may be shown as answers.
Disable dockcommand?
6 Answers 50 Views
This is a migrated thread and some comments may be shown as answers.
AereoN
Top achievements
Rank 1
AereoN asked on 21 Oct 2009, 09:32 AM
May i know what's the client side command to disable/enable the dockcommand?

Thanks.

6 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 26 Oct 2009, 11:51 AM
Hello,

You should use the set_visible(true/false) method of the dock-command client object. For example the following project disables/enables the close command of a RadDock: 

<%@ 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>
    <telerik:RadScriptBlock runat="server">
 
        <script type="text/javascript">
 
            function EnableCommand()
            {
                var dock = $find("<%=RadDock1.ClientID %>");
                var commands = dock.get_commands();
 
                //Get a reference to a command by commands["CommandName"]
                var closeCommand = commands["Close"];
 
                closeCommand.set_visible(!closeCommand.get_visible());
            }
        </script>
 
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <input value="Enable/Disable Close command" onclick="EnableCommand(); return false;"
        type="button" />
    <div>
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
            <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="400px" Width="300px">
                <telerik:RadDock ID="RadDock1" runat="server" Width="300px" Title="RadDock-Title">
                    <ContentTemplate>
                        <br />
                        <br />
                        <br />
                        <br />
                        <br />
                        CONTENT
                        <br />
                        <br />
                        <br />
                        <br />
                        <br />
                    </ContentTemplate>
                </telerik:RadDock>
            </telerik:RadDockZone>
        </telerik:RadDockLayout>
    </div>
    </form>
</body>
</html>


All the best,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
AereoN
Top achievements
Rank 1
answered on 30 Oct 2009, 10:11 AM
I'm referring to the custom button that is located at the top right of a dock, not the dock itself.
Is there anyway for me to set visible for the custom dock command button?
0
Accepted
Pero
Telerik team
answered on 03 Nov 2009, 09:16 AM
Hi,

You can set the Name property of the Custom Command and access it through its name (similar to the pre-defined dock commands). I have modified the project that I have sent you earlier to show/hide a Custom Command. It has Name="CustomCommand".

<%@ 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>
    <telerik:RadScriptBlock runat="server">
 
        <script type="text/javascript">
 
            function EnableCommand()
            {
                var dock = $find("<%=RadDock1.ClientID %>");
                var commands = dock.get_commands();
 
                //Get a reference to a command by commands["CommandName"]
                var closeCommand = commands["Close"];
                commands["CustomCommand"].set_visible(!(commands["CustomCommand"].get_visible()));
 
                closeCommand.set_visible(!closeCommand.get_visible());
            }
        </script>
 
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <input value="Enable/Disable Close and Customcommand" onclick="EnableCommand(); return false;"
        type="button" />
    <div>
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
            <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="400px" Width="300px">
                <telerik:RadDock ID="RadDock1" runat="server" Width="300px" Title="RadDock-Title">
                    <Commands>
                        <telerik:DockCloseCommand />
                        <telerik:DockExpandCollapseCommand />
                        <telerik:DockCommand Name="CustomCommand" />
                    </Commands>
                    <ContentTemplate>
                        <br />
                        <br />
                        <br />
                        <br />
                        <br />
                        CONTENT
                        <br />
                        <br />
                        <br />
                        <br />
                        <br />
                    </ContentTemplate>
                </telerik:RadDock>
            </telerik:RadDockZone>
        </telerik:RadDockLayout>
    </div>
    </form>
</body>
</html>




Regards,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
AereoN
Top achievements
Rank 1
answered on 03 Nov 2009, 10:56 AM
Thanks Pero.

Sorry for not looking properly on the 1st solution you gave me.
That's what I'm looking for.
Anyway can it be done on server side?

Thanks.
0
Accepted
Pero
Telerik team
answered on 05 Nov 2009, 11:49 AM
Hello,

On the server side you can follow two approaches for enabling/disabling DockCommands:

1. Use the RadDock.DefaultCommands property to set which commands will be used.

2. Use the RadDock.Commands object of type List<DockCommand> to Add or Remove desired commands. For example the following code line will remove the command the first command in the Commands list:

RadDock1.Commands.Remove(RadDock1.Commands[0]);
 


Sincerely yours,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
AereoN
Top achievements
Rank 1
answered on 06 Nov 2009, 03:10 AM
Thanks Pero once again.

I found another alternative way to do that is by setting the css visibility false as well.
Tags
Dock
Asked by
AereoN
Top achievements
Rank 1
Answers by
Pero
Telerik team
AereoN
Top achievements
Rank 1
Share this question
or