Disable dockcommand?

7 posts, 2 answers
  1. AereoN
    AereoN avatar
    36 posts
    Member since:
    Oct 2009

    Posted 21 Oct 2009 Link to this post

    May i know what's the client side command to disable/enable the dockcommand?

    Thanks.
  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 26 Oct 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. AereoN
    AereoN avatar
    36 posts
    Member since:
    Oct 2009

    Posted 30 Oct 2009 Link to this post

    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?
  5. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 03 Nov 2009 Link to this post

    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.
  6. AereoN
    AereoN avatar
    36 posts
    Member since:
    Oct 2009

    Posted 03 Nov 2009 Link to this post

    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.
  7. Answer
    Pero
    Admin
    Pero avatar
    1156 posts

    Posted 05 Nov 2009 Link to this post

    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.
  8. AereoN
    AereoN avatar
    36 posts
    Member since:
    Oct 2009

    Posted 05 Nov 2009 Link to this post

    Thanks Pero once again.

    I found another alternative way to do that is by setting the css visibility false as well.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017