RadDock DockMode

2 posts, 0 answers
  1. Yet
    Yet avatar
    1 posts
    Member since:
    Aug 2012

    Posted 28 Aug 2012 Link to this post

    As i know about DockMode had 3 modes with: default, Docked, & floating..
    Is it possible for RadDock to enable drag and reset to default position after client-side loading without postBack?
    And any setting to mention for it to reset back to default position?
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 31 Aug 2012 Link to this post

    Hello Yet,

    If I understand you correctly, you want to be able to store original position of RadDock before dragging it and restore it at certain point. To do so, you need to handler RadDock's ClientDragStart client-side event and get its top a left position, e.g.:
    <telerik:RadDock ID="RadDock1" runat="server" OnClientDragStart="dockDragStart">
        <ContentTemplate>
            Some<br />
            Sample<br />
            Content
        </ContentTemplate>
    </telerik:RadDock>
    <asp:HiddenField ID="dockPositionHolder" runat="server" />
    <asp:Button Text="Restore position" runat="server" OnClientClick="restoreDockPosition(); return false;" />
    <script type="text/javascript">
        function dockDragStart(dock, args)
        {
            var posStr = "{\"top\": "+ dock.get_top()+",\"left\": "+dock.get_left()+"}"; //JSON formatted data to be stored
     
            $get("<%=dockPositionHolder.ClientID %>").value = posStr;
        }
     
        function restoreDockPosition()
        {
            var posObj = $telerik.$.parseJSON($get("<%=dockPositionHolder.ClientID %>").value);//get the JSON data as JavaScript object
            var dock = $find("<%=RadDock1.ClientID %>"); //get reference to the RadDock client-side object
     
            if(dock)
            {
                //set dock's original position
                dock.set_top(posObj.top);
                dock.set_left(posObj.left);
            }
        }
    </script>


    Kind regards,
    Dobromir
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top