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

Chart renders with jscript error

2 Answers 30 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 30 Jul 2010, 08:40 PM
I recently upgraded to Telerik Reporting Q1 2010 and to VS2010.  I have a reporting project where most of my charts have converted up and run fine.  However I have one page where I render 4 charts on one page, and I'm getting 4 jscript errors:

Object required  Telerik.ReportViewer.axd?optype=Resource&version=4.0.10.423&name=Resources.ReportViewer.js, line 430 character 5

from this function:
ReportViewer.prototype.get_Height = function()
{
    var reportTable = document.getElementById(this.reportTableId);
    var lastRow = reportTable.rows[reportTable.rows.length - 1];
    var oldDisplay = lastRow.style.display;
    lastRow.style.display = "none";
  
    var viewer = document.getElementById(this.clientID);
    var clientHeight = viewer.clientHeight;
    lastRow.style.display = oldDisplay;
    return clientHeight;
}

The failure is caused by var viewer being null.
Any ideas?
Dan

2 Answers, 1 is accepted

Sort by
0
Dan
Top achievements
Rank 2
answered on 02 Aug 2010, 09:22 PM
FYI, I found a work-around for this problem.  The code which generates the jscript error is this:
<asp:Content ID="Content1" ContentPlaceHolderID="cphWebData" Runat="Server">
    <div id="chartdiv" runat="server">
        <center>
        <table width="85%">
            <tr>
                <td width="50%">
                    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                </td>
                <td width="50%">
                    <asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder>
                </td>
            </tr>
  
protected void Page_Load(object sender, EventArgs e)
{
    Telerik.ReportViewer.WebForms.ReportViewer rv;
    rv = new Telerik.ReportViewer.WebForms.ReportViewer();
        rv.Width = Unit.Percentage(100);
        rv.Height = Unit.Pixel(290);
        rv.ToolbarVisible = false;
    rv.Report = new NewReferralsChart(myConnectionstring, false);
    this.PlaceHolder1.Controls.Add(rv);

I was adding the report viewer into a placeholder in the html.  This worked ok with the older version of Reporting, but not so good with Q1 2010.  To avoid the problem I got rid of the placeholders, thus:
<asp:Content ID="Content1" ContentPlaceHolderID="cphWebData" Runat="Server">
    <div id="chartdiv" runat="server">
        <center>
        <table width="85%">
            <tr>
                <td width="50%">
                    <telerik:ReportViewer ID="ReportViewer1" runat="server" Width="100%" Height="290px" ToolbarVisible="false" ShowNavigationGroup="False" />
                </td>
                <td width="50%">
                    <telerik:ReportViewer ID="ReportViewer2" runat="server" Width="100%" Height="290px" ToolbarVisible="false" ShowNavigationGroup="False" />
                </td>
            </tr>
  
protected void Page_Load(object sender, EventArgs e)
{
    Telerik.ReportViewer.WebForms.ReportViewer rv;
    rv = new Telerik.ReportViewer.WebForms.ReportViewer();
        rv.Width = Unit.Percentage(100);
        rv.Height = Unit.Pixel(290);
        rv.ToolbarVisible = false;
    rv.Report = new NewReferralsChart(myConnectionstring, false);
    ReportViewer1.Report = rv.Report;

And no more jscript errors.

Dan
0
Accepted
Peter
Telerik team
answered on 03 Aug 2010, 12:34 PM
Hi Dan,

Thank you for elaborating.

This is a known issue related to a missing report viewer ID when a report viewer is created in code behind. The fix was introduced with the Q2 2010 release and our suggestion is to use the latest version of Telerik Reporting. If this is not possible, you can just set the report viewer's ID as shown in the following code snippet:

protected void Page_Load(object sender, EventArgs e)
{
    Telerik.ReportViewer.WebForms.ReportViewer rv;
    rv = new Telerik.ReportViewer.WebForms.ReportViewer();
        rv.ID = "reportviewer1";
        rv.Width = Unit.Percentage(100);
        rv.Height = Unit.Pixel(290);
        rv.ToolbarVisible = false;
    rv.Report = new NewReferralsChart(myConnectionstring, false);
    this.PlaceHolder1.Controls.Add(rv);

All the best,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Dan
Top achievements
Rank 2
Answers by
Dan
Top achievements
Rank 2
Peter
Telerik team
Share this question
or