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

Open RadWindow using Javascript and cpature OnClientDragEnd

2 Answers 98 Views
Window
This is a migrated thread and some comments may be shown as answers.
Louise
Top achievements
Rank 1
Louise asked on 24 Sep 2013, 02:59 PM
Hi,

Is it possible to capture the position of a RadWindow opened using JavaScript?
I am opening a RadWindow using the code below. After opening and then moving the RadWindow a function OnClientDragEnd is not called. I need to capture the position of a rad window so that I can re-open it after a postback.

function OpenWnd(Title, Url) {

var oWindow = window.radopen(Url, null);

oWindow.SetSize(800, 500);

oWindow.SetTitle(Title);

oWindow.SetModal(false);

oWindow.Center();

oWindow.set_status('');

oWindow.OnClientDragEnd = "OnClientDragEnd";

}

function OnClientDragEnd(sender, args) {

alert('aaa');

var position = sender.getWindowBounds();

var x = position.x;

var y = position.y;

var ht = position.height;

var w = position.width;

 

}

Many thanks

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 25 Sep 2013, 07:53 AM
Hi Louise,

To add OnClientDragEnd event to the RadWindow from JavaScript you should follow the below approach.
oWindow.add_dragEnd(OnClientDragEnd);

Please have a look into the following full code I tried to achieve your scenario.

ASPX:
<telerik:RadButton ID="RadButton1" runat="server" Text="Open RadWindow" OnClientClicked="openRadWindow"
    AutoPostBack="false">
</telerik:RadButton>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Web20" VisibleStatusbar="false"
    ShowContentDuringLoad="false">
</telerik:RadWindowManager>
<br />
<span id="showCoordinates"></span>

JavaScript:
<script type="text/javascript">
    function openRadWindow(sender, args) {
        var oWindow = window.radopen("http://www.telerik.com", null);
        oWindow.SetSize(700, 400);
        oWindow.SetTitle("Teleriks");
        oWindow.SetModal(true);
        oWindow.Center();
        oWindow.add_dragEnd(OnClientDragEnd);
    }
 
    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>

Thanks,
Shinu.
0
Louise
Top achievements
Rank 1
answered on 25 Sep 2013, 08:18 AM
Thank you - works great, just what I needed.
Tags
Window
Asked by
Louise
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Louise
Top achievements
Rank 1
Share this question
or