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

How would you create a command clientside in the dock bar?

1 Answer 74 Views
Dock
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 23 Jan 2011, 06:20 PM
I am unable to add the command in the serverside code, but I can attach to the dock item clientside.

Is there some function to add a new command item?  I can't see how I would do that in the docs

1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 25 Jan 2011, 03:17 PM
Hi Steve,

By default the dock commands cannot be created on the client, but with custom JavaScript code a command this can be achieved. Here is an example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="RadScriptManager1" runat="server">
    </asp:ScriptManager>
    <script type="text/javascript">
        function CreateClick()
        {
            var dock = $find("RadDock1");
 
            var li = document.createElement("li");
            var anchor = document.createElement("a");
            anchor.setAttribute("title", "Command Text");
            var span = document.createElement("span");
 
            anchor.appendChild(span);
            li.appendChild(anchor);
            dock.get_commandsContainer().appendChild(li);
 
            Sys.UI.DomElement.addCssClass(span, "rdCustom");
            var command = $create(Telerik.Web.UI.DockCommand, null, null, null, anchor);
            command.set_radDock(dock);
            command.radDock = dock;
 
            dock.get_commands()["CommandName"] = command;
            dock.repaint();
        }
    </script>
    <div>
        <input type="button" onclick="CreateClick();" value="Add Command" />
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server">
            <telerik:RadDockZone ID="RadDockZone1" runat="server" MinHeight="300px" Width="300px">
                <telerik:RadDock ID="RadDock1" runat="server" Title="RadDock-Title" Width="300px"
                    Height="300px">
                    <Commands>
                        <telerik:DockCloseCommand />
                    </Commands>
                    <ContentTemplate>
                    </ContentTemplate>
                </telerik:RadDock>
            </telerik:RadDockZone>
        </telerik:RadDockLayout>
    </div>
    </form>
</body>
</html>


All the best,
Pero
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Dock
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Pero
Telerik team
Share this question
or