Get Bounds of Grid Client Side

6 posts, 2 answers
  1. Danny
    Danny avatar
    35 posts
    Member since:
    May 2012

    Posted 03 Oct 2013 Link to this post

    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>

     

     

     

  2. Answer
    Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 08 Oct 2013 Link to this post

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

    Posted 07 Nov 2013 Link to this post

    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.
  5. Answer
    Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 08 Nov 2013 Link to this post

    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.
  6. Danny
    Danny avatar
    35 posts
    Member since:
    May 2012

    Posted 21 Nov 2013 Link to this post

    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?
  7. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 22 Nov 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017