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

RadChart Resizing OnLoad

2 Answers 113 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Jocelyn
Top achievements
Rank 1
Jocelyn asked on 12 Mar 2012, 02:00 PM
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 Answers, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 15 Mar 2012, 02:23 PM
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.
0
Jocelyn
Top achievements
Rank 1
answered on 16 Mar 2012, 04:29 PM
Thanks Petar. I found a simple an easy way to achieve this:

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

Works very well.
Tags
Chart (Obsolete)
Asked by
Jocelyn
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Jocelyn
Top achievements
Rank 1
Share this question
or