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

How can I get current position of RadWindow in OnClientDragEnd

6 Answers 189 Views
Window
This is a migrated thread and some comments may be shown as answers.
Rabbi
Top achievements
Rank 1
Rabbi asked on 16 Nov 2011, 07:53 AM
 function OnClientDragEnd(sender,args) {
                var oWd = $find("RadWindow1");
                var newLocation = oWd.getWindowBounds();             
            }

 <cc:RadWindow runat="server" ID="RadWindow1" Height="300px" Width="400px"
                        NavigateUrl="http://yahoo.com" VisibleOnPageLoad="true" OnClientDragEnd="OnClientDragEnd" />

in this, getWindowBounds can't get new positon on fly. 
Please help me.

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Nov 2011, 09:27 AM
Hello,

Try the following javascript.
JS:
function OnClientDragEnd(sender, args)
{
  var position = sender.getWindowBounds();
  var x = position.x;
  var y= position.y;
  var ht = position.height;
  var w = position.width;
}        

Thanks,
Princy.
0
Rabbi
Top achievements
Rank 1
answered on 16 Nov 2011, 09:59 AM
thank Princy very much.

In this case, using  position = sender.getWindowBounds();  only get old postion of radwindows.

How to get current postion of radwindow during drag it?
0
Rumen
Telerik team
answered on 16 Nov 2011, 01:20 PM
Hi Rabbi,

The following code works for me:

<telerik:RadWindow ID="RadWindow1" VisibleOnPageLoad="true" Width="400" Height="400"
    OnClientDragStart="OnClientDragStart" OnClientDragEnd="OnClientDragEnd" runat="server" NavigateUrl="http://www.telerik.com"></telerik:RadWindow>
    <span id="showCoordinates"></span>
<script type="text/javascript">
    function OnClientDragStart(sender, args) {
        var position = sender.getWindowBounds();
        var x = position.x;
        var y = position.y;
        $get("showCoordinates").innerHTML = "Coordinates before drag: x:" + x + " y: " + y;
    }
 
    function OnClientDragEnd(sender, args) {
            var position = sender.getWindowBounds();
            var x = position.x;
            var y = position.y;
            $get("showCoordinates").innerHTML = "Coordinates after drag: x:" + x + " y: " + y;
    
</script>

The SPAN tag is updated with the new x and y coordinates of the dialog after the drag execution.

All the best,
Rumen
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
0
Rabbi
Top achievements
Rank 1
answered on 17 Nov 2011, 09:08 AM
hi Rumen,

your code win get old postion of radwindow.  I want to get current of radwindow in DRAG event 

Please help me.
0
Marin Bratanov
Telerik team
answered on 18 Nov 2011, 03:54 PM
Hi Rabbi,

Your initial question was for the coordinates in the OnClientDragEnd event and the code provided by my colleagues achieves this functionality. 

You can use the getBounds() method of the static client library we provide and an interval to get the current position while dragging:

<telerik:RadWindow ID="RadWindow1" VisibleOnPageLoad="true" Width="400" Height="400"
    OnClientDragStart="OnClientDragStart"  OnClientDragEnd="OnClientDragEnd" runat="server"
    NavigateUrl="http://www.telerik.com">
</telerik:RadWindow>
<span id="showCoordinates"></span>
<br />
<span id="currCoords"></span>
<script type="text/javascript">
    var timer = null;
    function OnClientDragStart(sender, args)
    {
        var position = sender.getWindowBounds();
        var x = position.x;
        var y = position.y;
        $get("showCoordinates").innerHTML = "Coordinates before drag: x:" + x + " y: " + y;
 
        var popupElem = sender.get_popupElement();
        timer = setInterval(function ()
        {
            var position = $telerik.getBounds(popupElem);
            var x = position.x;
            var y = position.y;
            $get("currCoords").innerHTML = "Current coordinates: x:" + x + " y: " + y;
        }, 10);
    }
 
 
    function OnClientDragEnd(sender, args)
    {
        clearInterval(timer);
        var position = sender.getWindowBounds();
        var x = position.x;
        var y = position.y;
        $get("showCoordinates").innerHTML = "Coordinates after drag: x:" + x + " y: " + y;
    }  
</script>

I am also attaching a simple page that shows this in action to this thread.

All the best,
Marin
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
0
Rabbi
Top achievements
Rank 1
answered on 23 Nov 2011, 08:48 AM
Dear Marin,

Your code is great for me.

Thank you very much!

Tags
Window
Asked by
Rabbi
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rabbi
Top achievements
Rank 1
Rumen
Telerik team
Marin Bratanov
Telerik team
Share this question
or