RadChart Resizing OnLoad

Thread is closed for posting
3 posts, 0 answers
  1. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 12 Mar 2012 Link to this post

    Hi,

    I am trying to resize my chart when the page load. Here is the code I have right now:

    JavaScript:
    $(document).ready(ResizeChart());
     
     
    function ResizeChart()
    {
        var ajaxManager = $find("<%= RadAjaxManager1.ClientID %>");
        var arg1 = $(document).width();
        var arg2 = 305;
        ajaxManager.ajaxRequest(arg1 + "," + arg2);
    }

    VB:
    Protected Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
        Dim argument As String = e.Argument
        Dim sArray As String() = argument.Split(",".ToCharArray())
        chartLabos.Width = CInt(sArray(0))
        chartLabos.Height = CInt(sArray(1))
    End Sub

    ResizeChart() is called on the onresize event on the Body and it works! But when it's called with the jQuery "$(document).ready" my variable ajaxManager is null, so I understand that the RadAjaxManager is not loaded at this time. How can I call ResizeChart() on the load of the RadChart? I can't find any ClientEvent for the RadChart.

    Thanks.
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 15 Mar 2012 Link to this post

    Hi Jocelyn,

    I have attached a project that demonstrates how to resize the chart  on page load. The resizing does not actually take place in pageLoad, but in OnClientLoad of a RadSplitter (which parents the chart).

    I hope that the proposed approach is applicable for your current project.  

    Regards,
    Petar Marchev
    the Telerik team
    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 their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jocelyn
    Jocelyn avatar
    148 posts
    Member since:
    Jul 2012

    Posted 16 Mar 2012 Link to this post

    Thanks Petar. I found a simple an easy way to achieve this:

    $(window).load(function()
    {
        Resize();
     
        $(window).resize(function()
        {
            Resize();
        });
    });

    Works very well.
Back to Top