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

Get Bounds of Grid Client Side

5 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 2
Danny asked on 03 Oct 2013, 03:35 PM

Is it possible to get the X and Y coordinates of a radgrid that has just been made visible?   I want to scroll to the top of it as soon as it has been created.

 

 

<script type="text/javascript">
            function rgOrderDetail_OnGridCreated(sender, args) {
                var bounds = //get bounds of the grid
                scrollTo(bounds.x, bounds.y);
             }  
</script>

 

 

 

5 Answers, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 08 Oct 2013, 08:02 AM
Hi Danny,

You can use the following approach:
function gridCreated(sender, args) {
    var offset = $(sender.get_element()).offset();
    var top = offset.top;
    var left = offset.left;
}

Hope this helps. Please give it a try and let me know if it works for you.

Regards,
Eyup
Telerik
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 the blog feed now.
0
Danny
Top achievements
Rank 2
answered on 07 Nov 2013, 07:35 PM
Eyup, thanks for the stab at it.

Your first line of code is not returning an object- I'm getting an "Object Expected" error.

Using the .get_element() method off of merely the sender results in an object that doesn't support the offset() method.
0
Accepted
Eyup
Telerik team
answered on 08 Nov 2013, 09:36 AM
Hi Danny,

Can you please verify that you have jQuery scripts added to your page?
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    <Scripts>
        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
        <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    </Scripts>
</telerik:RadScriptManager>

Looking forward to your reply.

Regards,
Eyup
Telerik
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 the blog feed now.
0
Danny
Top achievements
Rank 2
answered on 21 Nov 2013, 02:32 PM
Yes, Eyup, I had created a second master page and did not have those scripts referenced in script manager.

The following works perfectly-
function rgOrderDetail_OnGridCreated(sender, args) {
                var offset = $(sender.get_element()).offset();
                var top = offset.top;
                window.scrollTo(0, top);
            }

Thank you for your help- can I award *you* Telerik points?
0
Eyup
Telerik team
answered on 22 Nov 2013, 11:58 AM
Hi Danny,

I am glad that the issue was resolved.
Your appreciation is totally enough.

Regards,
Eyup
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Danny
Top achievements
Rank 2
Answers by
Eyup
Telerik team
Danny
Top achievements
Rank 2
Share this question
or