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

cancel move in DockPositionChanged event

3 Answers 84 Views
Dock
This is a migrated thread and some comments may be shown as answers.
chookieeee
Top achievements
Rank 1
chookieeee asked on 08 Sep 2009, 12:44 AM
hi,
im creating my raddocks and everything else server side, which is working fine apart from one thing...

i'd like to be able to cancel a dock move in it's 'DockPositionChanged' event...
any way to do this?

i look at the dock control and it is in the original spot in this event and all page lifecycle (including PreRender)....

cheers,
dan

3 Answers, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 10 Sep 2009, 11:45 AM
Hello Dan,

It is not clear to me what exactly you are trying to achieve, but for your convenience I have created a simple project that asks the user whether s/he wants to move the dock and based on the answer it moves the dock to the new position or returns it to its original position. Please note, that in my project I am using a dock created at design time, but you can easily attach the client-side event handlers dynamically when the docks are added to the page and again when recreated in the Page_Init, by using RadDock.OnClientDragStart="OnClientDragStart" and RadDock.OnClientPositionChanged="OnClientPositionChanged".

Here is the full source code of the project:

<%@ 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"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head id="Head1" runat="server"
    <title></title
 
    <script type="text/javascript"
        var zone; 
        var zoneId = ""
        var index; 
        var Top; 
        var Left; 
        function OnClientDragStart(dock, args) 
        { 
            index = dock.get_index(); 
            zone = dock.get_dockZone(); 
            zoneId = dock.get_dockZoneID(); 
            Top = dock.get_top(); 
            Left = dock.get_left(); 
        } 
        function OnClientPositionChanged(dock, args) 
        { 
            var result = confirm("Do you want to move the RadDock?"); 
            if (result) 
                return; 
            if (zoneId != "") 
            { 
                zone.dock(dock, index); 
            } 
            else 
            { 
                if (dock.get_dockZoneID != "") 
                { 
                    dock.undock(); 
                } 
                dock.set_top(Top); 
                dock.set_left(Left); 
            } 
        } 
    </script> 
 
</head> 
<body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="ScriptManager1" runat="server"
    </asp:ScriptManager> 
    <div> 
        <telerik:RadDockLayout ID="RadDockLayout1" runat="server"
            <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="300px" Width="300px"
                <telerik:RadDock ID="RadDock1" AutoPostBack="true" runat="server" Width="300px" Title="RadDock-Title" 
                    OnClientDockPositionChanged="OnClientDragEnd" OnClientDragStart="OnClientDragStart"
                    <ContentTemplate> 
                        <br /> 
                        <br /> 
                        <br /> 
                        <br /> 
                        <br /> 
                        CONTENT 
                        <br /> 
                        <br /> 
                        <br /> 
                        <br /> 
                        <br /> 
                    </ContentTemplate> 
                </telerik:RadDock> 
            </telerik:RadDockZone> 
            <telerik:RadDockZone ID="RadDockZone2" runat="server" Height="300px" Width="300px"
            </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
chookieeee
Top achievements
Rank 1
answered on 13 Sep 2009, 07:18 AM
Hi Pero,

What i meant was, in the server side 'DockPositionChanged' event.... i would like to stop a dock from moving (cancel the move.. move it back to its original spot). not on client side, because i have some server side validation i would like to do.
is there any way to do this?

Thanks,
Dan
0
Pero
Telerik team
answered on 17 Sep 2009, 11:47 AM
Hello Dan,

It can be done on the server side too. I have modified the project so that the movement can be canceled on the server. Because in the DockPositionChanged event the new position (and the state) is not applied to the moved RadDock, we can get the initial position of the RadDock there and then in the Page_Load (here the position (state) is applied) event we decide whether or not the dock will be moved to the new position or it will stay in the original position. You can find the modified project attached to this thread.


Best wishes,
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.
Tags
Dock
Asked by
chookieeee
Top achievements
Rank 1
Answers by
Pero
Telerik team
chookieeee
Top achievements
Rank 1
Share this question
or