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

How to hide PageNumber in Reportviewer

7 Answers 429 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
john
Top achievements
Rank 1
john asked on 07 Jun 2011, 01:04 PM
Hi,

I'm evaluating your reporting library with some test samples. One of these is a report with serveral charts and tables (in the pageFooter section there is a textbox with the PageNumber object). When I preview in reportviewer, the report is shown without paging, and the page number value is always 1 (even if the rendered report size has two or more pages). When exporting to pdf the number of pages is correct (and also the page number field in the footer section).

Is it possible to hide the PageNumber field when previewing with Reportviewer (and show it when export to pdf or print)? I've seen your Invoice Report sample works in this way, but I don't know how to get that.

How can I display the correct pages and its numbers when previewing in Reportviewer (like the Preview tab in design mode in VS)? Is it possible?

Regards,
John.

7 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 07 Jun 2011, 03:09 PM
Hi John,

The output of a report rendered in HTML and PDF differs because both medias are quite different. The 1st (HTML) is dedicated to displaying information on screen and the page is infinite by width and height; in contrast the 2nd format - PDF - supports physical pages and is meant not only for reading on screen but for printing.

According to whether the format supports physical pages, we separate the export formats on two groups: page-oriented (PDF, Image (print preview), print, XPS, RTF) and non-page oriented (HTML/MHTML, Excel, CSV).

For the page-oriented formats the content layout is on horizontal and vertical pages according the the page settings of the report, while for the rest of the formats take into considerations other characteristics of the media like the grid of the Excel worksheet. So, it is design behavior to have a report show as a single page in the web viewer, while it shows correctly on several pages in page oriented formats.

As for the Invoice demo report, the page number is not shown because it is part of an expression using PageExec function which is not supported in HTML rendering (used by the web report viewer). If you want the exact same view on your page, our suggestion is to remove the viewer and export directly to PDF. Sample code for doing this is available in the Exporting a report to PDF programmatically KB article. Removing the Response.AddHeader line would force the PDF to display directly in the browser (you should have Adobe PDF plug-in installed) and users can save it directly.

All the best,
Steve
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
0
john
Top achievements
Rank 1
answered on 08 Jun 2011, 11:13 AM
Hi, Steve.

Thanks for your response.

I've tried to show the report directly using pdf format and it works fine (it could be a solution). I use a RadWindow to embed the pdf report and it works fine in FireFox, but not in IExplorer because report never shows (the plugin is installed, if I drop a pdf file on the browser it's showed correctly). Is there any kind of bug for this feature in IExplorer?

About the Reportviewer, the 'trick' of using PageExec to hide the pagenumber when previewing in html is not a good solution. Is there any other way of controlling that? I would like to hide pagenumber when preview in html and show when render to other format that supports page formatting.

Does the web Reportviewer support only html render mode? Is it possible to set another way of render with page formatting (programmatically)?

Regards,
John
0
Steve
Telerik team
answered on 09 Jun 2011, 01:35 PM
Hello John,

The ReportProcessor object is used to create a stream of bytes and write those bytes to the ASP.NET Response object. This approach is a standard one and works correctly in all browsers. If there is a problem, it might be related to the involvement of RadWindow, but we have not been able to reproduce it on our end. Verify that you are using the latest version of RadControls for ASP.NET AJAX and if the problem persists, you can provide us with a sample that shows the problem or open a support inquiry to our RadWindow team.

About the PageExec function - there is no trick involved, we simply have not implemented this function for the HTML rendering yet and that is the reason it does not work. So the behavior you observe in our examples (showing PageCount/PageNumber) in PDF and not in HTML is not intentional.
Generally you can check whether you're in the context of a web page through the HttpContext Class and if you check for the exportType as well, you would be able to show the page info for all other formats except HTML and MHTML e.g.:

private void textBox2_ItemDataBinding(object sender, EventArgs e)
       {
           Telerik.Reporting.Processing.TextBox txt = (Telerik.Reporting.Processing.TextBox)sender;
           HttpContext context = System.Web.HttpContext.Current;
                     
           if (context != null)
           {
               string exportFormat = context.Request.QueryString["ExportFormat"];
               string opType = context.Request.QueryString["optype"];
               if ((opType == "Report") || ((opType == "Export") && (exportFormat == "MHTML")))
               {
                   txt.Value = String.Empty;
               }
           }
       }

where txt is the processing counterpart of the textbox in the page footer with the following expression

= 'Page ' + PageNumber + ' of ' + PageCount


All the best,
Steve
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
0
john
Top achievements
Rank 1
answered on 10 Jun 2011, 07:50 AM
Hello, Steve.

About hiding PageNumber when previewing in HTML mode, I've solved the problem using your code.

About showing the report in PDF format inside a RadWindow, it works with Firefox (4), but not with Internet Explorer (8). I've tried the latest release of RadControls but the problem persists. The sample has a main page, with a button and a RadWindowManager with the window that will show the report:
- MainProg.aspx:
...
    <form id="form1" runat="server">
    <div>
     
        <telerik:RadButton ID="rbtnVerReport" runat="server"
            onclick="rbtnVerReport_Click" Text="Ver informe">
        </telerik:RadButton>
     
    </div>
    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="mainAjaxManager" runat="server">
    </telerik:RadAjaxManager>
    <telerik:RadWindowManager ID="mainWindowManager" runat="server">
        <Windows>
            <telerik:RadWindow ID="rwDlgReport" runat="server" AnimationDuration="1000"
                AutoSize="True" Behavior="Resize, Close, Maximize, Move" Behaviors="Resize, Close, Maximize, Move"
                EnableShadow="True" Modal="True" NavigateUrl="~/MainDlgReportProg.aspx"
                ReloadOnShow="True" ShowContentDuringLoad="False" style="display:none;"
                Title="Informe" VisibleStatusbar="False" Height="500px" Width="500px">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
     
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
    </telerik:RadScriptBlock>
        <script type="text/javascript">
            function AbrirDlgReport() {
                var manager = $find('<%= mainWindowManager.ClientID %>');
                if (manager == null)
                    return;
                manager.open('MainDlgReportProg.aspx', 'rwDlgReport');
            }
        </script>
    </form>
...
 
- MainProg.cs:
...
        protected void rbtnVerReport_Click(object sender, EventArgs e)
        {
       mainAjaxManager.ResponseScripts.Add("AbrirDlgReport();");
        }
...


The aspx with the content for the RadWindow to display the report:
- MainDlgReportProg.aspx:
...
<head id="Head1" runat="server">
    <title></title>
    <style type="text/css">          
        html#html, body#body, form#form1, div#content, center#center
        {  
            border: 0px solid black;
            padding: 0px;
            margin: 0px;
            height: 100%;
        }
    </style>
 
</head>
<body>
    <form id="form1" runat="server">
    <div id="content">
        <center id="center">
            <telerik:ReportViewer ID="rptViewer" runat="server" Height="100%"  Width="100%"               
                Report="Reports.RptGraficoNodos, Reports, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
                 ShowNavigationGroup="False" ShowZoomSelect="True">
            </telerik:ReportViewer>
        </center>
    </div>
    </form>
</body>
...
 
- MainDlgReportProg.cs:
 
        protected void Page_Load(object sender, EventArgs e)
        {
            RptGraficoNodos rpt = new RptGraficoNodos();
            ChartSeriesItem i;
            Random rnd = new Random();
 
            for (int j=0; j<5; j++)
            {
                i = new ChartSeriesItem();
                i.XValue = j;
                i.YValue = rnd.Next(100, 500); ;
                i.Name = string.Format("Data {0}", j);
                 
                rpt.rdGrafico.Series[0].AddItem(i);               
            }
 
            rpt.rdGrafico.Series[0].DefaultLabelValue = "#%";                     
 
            /*
            rptViewer.Report = rpt;
            rptViewer.RefreshReport();
             */
 
            ExportToPDFAndShow(rpt);
        }
 
        private void ExportToPDFAndShow(RptGraficoNodos rpt)
        {
            ReportProcessor reportProcessor = new ReportProcessor();
            RenderingResult result = reportProcessor.RenderReport("PDF", rpt, null);
 
            string fileName = result.DocumentName + ".pdf";
 
            Response.Clear();
            Response.ContentType = result.MimeType;
            Response.Cache.SetCacheability(HttpCacheability.Private);
            Response.Expires = -1;
            Response.Buffer = true;
 
            //Response.AddHeader("Content-Disposition", string.Format("{0};FileName=\"{1}\"",
            //    "attachment", fileName));
 
            Response.BinaryWrite(result.DocumentBytes);
            Response.End();
        }

And a last question.... Is it possible to center the web ReportViewer toolbar in its container (for example a RadWindow, resizable and maximizable)?

Thanks for your help.

Regards,
John.
0
Steve
Telerik team
answered on 14 Jun 2011, 03:19 PM
Hi John,

Thanks for the code - it helped us reproduce the issue which is not related neither to Telerik Reporting, nor to RadWindow. The problem is related to the Loading image of RadWindow, which is supposed to be hidden on onload. However in the Response, we change the content type to a file and not a page and the loading image is displayed indefinitely because there is no code to tell it otherwise. This works in Firefox, as the page life cycle is executed a bit faster and differently under it i.e. the onload is fired before we change the Response.
To avoid this problem, simply remove the ShowContentDuringLoad="False" from the Window markup.

All the best,
Steve
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
0
john
Top achievements
Rank 1
answered on 14 Jun 2011, 05:32 PM
Hi, Steve.

Thanks again. I've tested removing ShowContentDuringLoad="False" and it works fine.

Any suggestion for my last question in the previous post? (How to center the items in the ReportViewer toolbar -zoom, export listbox and link, print button-).

Regards,
John.

0
Accepted
Steve
Telerik team
answered on 15 Jun 2011, 07:35 AM
Hello John,

The Toolbar of the report viewer is not customizable. The only way to achieve centered items is if you hide the Toolbar and create your own UI for this purpose.
Your question in your previous post is a bit different (resizing the viewer in the radwindow), which is achievable. For more info refer to the following video: Using Telerik ReportViewer in RadWindow.

Regards,
Steve
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
john
Top achievements
Rank 1
Answers by
Steve
Telerik team
john
Top achievements
Rank 1
Share this question
or