LirenZhao's Blog
C0#1J0a1v0a1r0u0b1y0r1a1i1ls0f0l0e0x01
gtalk:lirnzhao#gmail.com
随笔- 45 文章- 0 评论- 56
首页
新随笔
新文章
联系
管理
订阅
Flex 打印DataGrid内容 2.0
<?
xml version="1.0" encoding="utf-8"
?>
<
mx:VBox
xmlns:mx
="http://www.adobe.com/2006/mxml"
xmlns
="*"
backgroundColor
="#FFFFFF"
fontFamily
="simsun"
fontSize
="12"
paddingTop
="50"
paddingBottom
="50"
paddingLeft
="30"
paddingRight
="30"
height
="268"
width
="748"
>
<
mx:Script
>
<![CDATA[
import mx.controls.DateField;
import mx.core.*
import mx.collections.ArrayCollection;
import mx.printing.*;
[Bindable]
private var pageNumber:Number = 1;
[Bindable]
private var prodTotal:Number = 0;
[Bindable]
private var reportTitle:String = "报表标题";
[Bindable]
private var datetime:String = "";
public static var footerHeight:Number = 20;
public static var prodIndex:Number;
public static var prodTotal:Number = 0;
public static function doPrint(datap:Object,title:String,columns:Array):void {
var printJob:FlexPrintJob = new FlexPrintJob();
if (printJob.start()) {
var thePrintView:FormPrintView = new FormPrintView();
Application.application.addChild(thePrintView);
thePrintView.reportTitle = title;
thePrintView.datetime = mx.controls.DateField.dateToString(new Date(),"YYYY年MM月DD日");
thePrintView.printDataGrid.columns = columns;
thePrintView.width=printJob.pageWidth;
thePrintView.height=printJob.pageHeight;
thePrintView.prodTotal = (datap as ArrayCollection).length;
thePrintView.printDataGrid.dataProvider = datap;//设置数据v
thePrintView.showPage("single");
if(!thePrintView.printDataGrid.validNextPage){
printJob.addObject(thePrintView);
}
else{
thePrintView.showPage("first");
printJob.addObject(thePrintView);
thePrintView.pageNumber++;
while(true){
thePrintView.printDataGrid.nextPage();
thePrintView.showPage("last");
if(!thePrintView.printDataGrid.validNextPage) {
printJob.addObject(thePrintView);
break;
}
else{
thePrintView.showPage("middle");
printJob.addObject(thePrintView);
thePrintView.pageNumber++;
}
}
}
Application.application.removeChild(thePrintView);
}
printJob.send();
}
private function showPage(pageType:String):void {
if(pageType == "first" || pageType == "middle") {
footer.includeInLayout=false;
footer.visible = false;
}
if(pageType == "middle" || pageType == "last") {
header.includeInLayout=false;
header.visible = false;
}
if(pageType == "last") {
// Show the footer.
footer.includeInLayout=true;
footer.visible = true;
}
//Update the DataGrid layout to reflect the results.
validateNow();
}
]]>
</
mx:Script
>
<!--
The template for the printed page, with the contents for all pages.
-->
<
mx:VBox
width
="100%"
horizontalAlign
="left"
>
<
mx:Label
text
="第 {pageNumber}页"
color
="#9e9e9e"
/>
<
mx:Label
id
="header"
text
="{reportTitle}"
fontWeight
="bold"
fontSize
="21"
textAlign
="center"
width
="100%"
/>
<
mx:HRule
width
="100%"
height
="1"
strokeColor
="#000000"
/>
</
mx:VBox
>
<
mx:PrintDataGrid
id
="printDataGrid"
width
="100%"
height
="100%"
fontFamily
="simsun"
fontSize
="12"
/>
<
mx:VBox
width
="100%"
horizontalAlign
="left"
id
="footer"
>
<
mx:Spacer
height
="100%"
/>
<
mx:HRule
width
="100%"
height
="1"
strokeColor
="#000000"
/>
<
mx:HBox
width
="100%"
>
<
mx:Label
text
="记录总数:{prodTotal}"
/>
<
mx:Spacer
width
="100%"
/>
<
mx:Label
text
="打印日期:{datetime}"
/>
</
mx:HBox
>
</
mx:VBox
>
</
mx:VBox
>
posted on 2007-01-24 20:14
LirenZhao
阅读(1554)
评论(3)
编辑
收藏
网摘
所属分类:
.Flex
评论
回复
引用
2008-07-10 13:58 |
LIUt[未注册用户]
能给我发一个这个程序的完整版不?我想看看分页的时候怎么处理的
回复
引用
2008-09-18 04:22 |
sam99[未注册用户]
Where is FormPrintView()?
回复
引用
2009-04-13 20:47 |
Steven Mo[未注册用户]
转载也转完整下...
刷新评论
切换模板
发表评论
昵称:
[登录]
[注册]
主页:
邮箱:
(仅博主可见)
验证码:
看不清,换一个
评论内容:
登录
注册
[使用Ctrl+Enter键快速提交评论]
0
629603
导航:
网站首页
社区
新闻
博问
闪存
网摘
招聘
找找看
Google搜索
China-pub 计算机图书网上专卖店!6.5万品种 2-8折!
China-Pub 计算机绝版图书按需印刷服务
相关文章:
最新IT新闻:
预测:Twitter最可能收购的十家公司
网易澄清:与暴雪合资公司仅提供技术支持
杰克逊悼念仪式或成史上最大规模Web活动
《商业周刊》:Mozilla的志愿者开发模式被复制
Mono 的Virtual PC 虚拟机
相关链接:
公告
这这里显示的是是公告,不不是母告
<
2007年1月
>
日
一
二
三
四
五
六
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
与我联系
发短消息
搜索
常用链接
我的随笔
我的空间
我的短信
我的评论
更多链接
我的参与
我的新闻
最新评论
我的标签
随笔分类
(43)
.Flex(18)
.NET(3)
.NET CF(13)
.OTHERS(4)
.Python(2)
Ruby On Rails(3)
收藏夹
(2)
Flex(2)
最新随笔
1. Python 学习笔记:需要仔细阅读一个函数
2. Python 学习笔记: 备份工具
3. ubuntu英文环境下使用中文输入法
4. 《20分钟体验 Ruby》通过这个例子你能感受ruby
5. 体验Android:个人所得税计算器 含源码
6. C# CRC8实现
7. RoR: Ruby On Rails Web Service 3 分发模式
8. RoR: Ruby On Rails 的 Web Service 2 使用before_invocation进行验证调用权限
9. Flex 动态切换css
10. Flex 调用添加了SoapHeader的web service