彩票走势图

使用XtraReports时,如何在web程序的运行时状态下缩放报表

原创|其它|编辑:郝浩|2012-09-29 09:41:06.000|阅读 557 次

概述:通过ReportViewer查看报表时,要实现报表的缩放功能,需要在运行时根据保存到HiddenField中 ScaleFactor值,调整XtraReport.PrintingSystem.Document.ScaleFactor属性。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

通过ReportViewer查看报表时,要实现报表的缩放功能,需要在运行时根据保存到HiddenField中 ScaleFactor值,调整XtraReport.PrintingSystem.Document.ScaleFactor属性。

要修改HiddenField值,需要创建自定义ReportToolbar按钮(ReportToolbarComboBox)。

请注意,Document.ScaleFactor属性不影响报表的页面大小,所以你可能需要使用当前的比例值手动改变页面大小。

C#

<%@ Page Language="C#" AutoEventWireup="true" CodeFile=";Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="DevExpress.XtraReports.v11.2.Web, Version=11.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.XtraReports.Web" TagPrefix="dxxr" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="//www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">
function UpdateScaleFactor(sender) {
document.getElementById('Scale').value = sender.GetText();
viewer.Refresh();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<dxxr:ReportToolbar ID="ReportToolbar1" runat="server" ShowDefaultButtons="False" ReportViewer="<%# ReportViewer1 %>">
<Items>
<dxxr:ReportToolbarButton ItemKind="Search" ToolTip="Display the search window" />
<dxxr:ReportToolbarSeparator />
<dxxr:ReportToolbarButton ItemKind="PrintReport" ToolTip="Print the report" />
<dxxr:ReportToolbarButton ItemKind="PrintPage" ToolTip="Print the current page" />
<dxxr:ReportToolbarSeparator />
<dxxr:ReportToolbarButton Enabled="False" ItemKind="FirstPage" ToolTip="First Page" />
<dxxr:ReportToolbarButton Enabled="False" ItemKind="PreviousPage" ToolTip="Previous Page" />
<dxxr:ReportToolbarLabel Text="Page" />
<dxxr:ReportToolbarComboBox ItemKind="PageNumber" Width="65px">
</dxxr:ReportToolbarComboBox>
<dxxr:ReportToolbarLabel Text="of" />
<dxxr:ReportToolbarTextBox ItemKind="PageCount" />
<dxxr:ReportToolbarButton ItemKind="NextPage" ToolTip="Next Page" />
<dxxr:ReportToolbarButton ItemKind="LastPage" ToolTip="Last Page" />
<dxxr:ReportToolbarSeparator />
<dxxr:ReportToolbarButton ItemKind="SaveToDisk" ToolTip="Export a report and save it to the disk" />
<dxxr:ReportToolbarButton ItemKind="SaveToWindow" ToolTip="Export a report and show it in a new window" />
<dxxr:ReportToolbarComboBox ItemKind="SaveFormat" Width="70px">
<Elements>
<dxxr:ListElement Text="Pdf" Value="pdf" />
<dxxr:ListElement Text="Xls" Value="xls" />
<dxxr:ListElement Text="Rtf" Value="rtf" />
<dxxr:ListElement Text="Mht" Value="mht" />
<dxxr:ListElement Text="Text" Value="txt" />
<dxxr:ListElement Text="Csv" Value="csv" />
<dxxr:ListElement Text="Image" Value="png" />
</Elements>
</dxxr:ReportToolbarComboBox>
<dxxr:ReportToolbarSeparator />
<dxxr:ReportToolbarLabel Text="Zoom Factor" />
<dxxr:ReportToolbarComboBox Name="ScaleFactor" Width="50px">
<Elements>
<dxxr:ListElement Text="100" Value="100" />
<dxxr:ListElement Text="200" Value="200" />
<dxxr:ListElement Text="250" Value="250" />
</Elements>
</dxxr:ReportToolbarComboBox>
<dxxr:ReportToolbarLabel Text="%" />
</Items>
<Styles>
<LabelStyle>
<Margins MarginLeft='3px' MarginRight='3px' />
</LabelStyle>
</Styles>
<ClientSideEvents ItemValueChanged="function(s, e) { UpdateScaleFactor(s) }" />
</dxxr:ReportToolbar>
<br />
<dxxr:ReportViewer ID="ReportViewer1" runat="server" ClientInstanceName="viewer">
</dxxr:ReportViewer>
<input id="Scale" runat="server" type="hidden" />
</div>
</form>
</body>
</html>

VB.NET

<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<%@ Register Assembly="DevExpress.XtraReports.v11.2.Web, Version=11.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.XtraReports.Web" TagPrefix="dxxr" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="//www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">
function UpdateScaleFactor(sender) {
document.getElementById('Scale').value = sender.GetText();
viewer.Refresh();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<dxxr:ReportToolbar ID="ReportToolbar1" runat="server" ShowDefaultButtons="False" ReportViewer="<%#ReportViewer1%>">
<Items>
<dxxr:ReportToolbarButton ItemKind="Search" ToolTip="Display the search window" />
<dxxr:ReportToolbarSeparator />
<dxxr:ReportToolbarButton ItemKind="PrintReport" ToolTip="Print the report" />
<dxxr:ReportToolbarButton ItemKind="PrintPage" ToolTip="Print the current page" />
<dxxr:ReportToolbarSeparator />
<dxxr:ReportToolbarButton Enabled="False" ItemKind="FirstPage" ToolTip="First Page" />
<dxxr:ReportToolbarButton Enabled="False" ItemKind="PreviousPage" ToolTip="Previous Page" />
<dxxr:ReportToolbarLabel Text="Page" />
<dxxr:ReportToolbarComboBox ItemKind="PageNumber" Width="65px">
</dxxr:ReportToolbarComboBox>
<dxxr:ReportToolbarLabel Text="of" />
<dxxr:ReportToolbarTextBox ItemKind="PageCount" />
<dxxr:ReportToolbarButton ItemKind="NextPage" ToolTip="Next Page" />
<dxxr:ReportToolbarButton ItemKind="LastPage" ToolTip="Last Page" />
<dxxr:ReportToolbarSeparator />
<dxxr:ReportToolbarButton ItemKind="SaveToDisk" ToolTip="Export a report and save it to the disk" />
<dxxr:ReportToolbarButton ItemKind="SaveToWindow" ToolTip="Export a report and show it in a new window" />
<dxxr:ReportToolbarComboBox ItemKind="SaveFormat" Width="70px">
<Elements>
<dxxr:ListElement Text="Pdf" Value="pdf" />
<dxxr:ListElement Text="Xls" Value="xls" />
<dxxr:ListElement Text="Rtf" Value="rtf" />
<dxxr:ListElement Text="Mht" Value="mht" />
<dxxr:ListElement Text="Text" Value="txt" />
<dxxr:ListElement Text="Csv" Value="csv" />
<dxxr:ListElement Text="Image" Value="png" />
</Elements>
</dxxr:ReportToolbarComboBox>
<dxxr:ReportToolbarSeparator />
<dxxr:ReportToolbarLabel Text="Zoom Factor" />
<dxxr:ReportToolbarComboBox Name="ScaleFactor" Width="50px">
<Elements>
<dxxr:ListElement Text="100" Value="100" />
<dxxr:ListElement Text="200" Value="200" />
<dxxr:ListElement Text="250" Value="250" />
</Elements>
</dxxr:ReportToolbarComboBox>
<dxxr:ReportToolbarLabel Text="%" />
</Items>
<Styles>
<LabelStyle>
<Margins MarginLeft='3px' MarginRight='3px' />
</LabelStyle>
</Styles>
<ClientSideEvents ItemValueChanged="function(s, e) { UpdateScaleFactor(s) }" />
</dxxr:ReportToolbar>
<br />
<dxxr:ReportViewer ID="ReportViewer1" runat="server" ClientInstanceName="viewer">
</dxxr:ReportViewer>
<input id="Scale" runat="server" type="hidden" />
</div>
</form>
</body>
</html>


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:DevExpress中文网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
相关产品
DevExpress Universal Subscription

优秀的界面控件开发包,帮助企业构建卓越应用!

DevExpress WPF Subscription

高效MVVM开发模式,WPF界面解决方案首选工具,帮助企业实现酷炫动效界面。

DevExpress Silverlight Controls

高性价比高实用性的Silverlight用户界面控件套包,拥有大量的示例和帮助文档,开发者能够快速上手!

DevExpress WinForms Subscription

为Windows Forms平台创建具有影响力的业务解决方案,高性价比WinForms界面控件套包。

DevExpress DXperience Subscription

高性价比的企业级.NET用户界面套包,助力企业创建卓越应用!

title
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP