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

radwindow get_top and get_left functions return null

3 Answers 56 Views
Window
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 29 Oct 2013, 11:04 AM
In our web application we open other web pages inside a radwindow within the application that show reports or graphs. I have a javascript function for the OnClientDragEnd event and in this event I just do an alert like the following

function newPosition(sender,args) {
alert('left='+sender.get_left()+'  top='+sender.get_top());
}

The alert shown states the left and top both equal null. I am using radwindowmanager and the event is set in here to be applied to the radwindows that are created. There is no restriction zone being applied so I dont know why I would not get values from these calls.


3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 30 Oct 2013, 06:34 AM
Hi Matthew,

Please have a look into the following code snippet to get the Left and Top position of the RadWindow on OnClientDragEnd event.

ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" VisibleOnPageLoad="true">
    <Windows>
        <telerik:RadWindow ID="RadWindow" runat="server" OnClientDragEnd="OnClientDragEnd"
            OnClientDragStart="OnClientDragStart" NavigateUrl="ButtonClickOpenWin.aspx">
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>

JavaScript:
<script type="text/javascript">
   var timer = null;
    function OnClientDragStart(sender, args)
    {
        var position = sender.getWindowBounds();
        var x = position.x;
        var y = position.y;
        var popupElem = sender.get_popupElement();
        timer = setInterval(function ()
        {
            var position = $telerik.getBounds(popupElem);
            var x = position.x;
            var y = position.y;
            
        }, 10);
    }
    function OnClientDragEnd(sender, args) {
        clearInterval(timer);
        var position = sender.getWindowBounds();
        var left = position.x;
        var top = position.y;
        alert("Coordinates after drag: Left:" + left + " Top: " + top);
    }
</script>

Thanks,
Shinu.
0
Henrik
Top achievements
Rank 2
answered on 14 Jan 2015, 07:56 AM
I'm seing the same problem here.
It seems like I need to use the method above, but isn't there an error in the documantaion then..  It states I can use the get_left and set_left:

http://www.telerik.com/help/aspnet-ajax/window-programming-radwindow-methods.html
0
Marin Bratanov
Telerik team
answered on 14 Jan 2015, 09:31 AM

Hi guys,

The correct method that will provide you with the current RadWindow dimensions is getWindowBounds(), as stated in the article Henrik linked about the client-side API of the RadWindow.

The get_left() and get_top() methods return the server Left and Top properties, as stated in the descriptions: "Corresponds to the Left server property." and "Corresponds to the Top server property." respectively.

I will also update the get_left() and get_top() decriptions to advise using the getWindowBounds() method, just like get_width() and get_height(). This change will be live with our next documentation upload.


Regards,

Marin Bratanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Window
Asked by
Matthew
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Henrik
Top achievements
Rank 2
Marin Bratanov
Telerik team
Share this question
or