Open RadWindow using Javascript and cpature OnClientDragEnd

3 posts, 1 answers
  1. Louise
    Louise avatar
    9 posts
    Member since:
    Oct 2012

    Posted 24 Sep 2013 Link to this post

    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. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 25 Sep 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Louise
    Louise avatar
    9 posts
    Member since:
    Oct 2012

    Posted 25 Sep 2013 Link to this post

    Thank you - works great, just what I needed.
Back to Top