- 浏览: 438046 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (211)
- 思考》感想 (11)
- 数据库操作 譬如Oracle大叔 (7)
- java,咱们有缘吗 (16)
- delphi,你还好吗 (2)
- SSH,哥三儿好 (31)
- 问题!问题?问题!? (9)
- WITH WORK (1)
- 算法与模式 莫事^_^ (10)
- JSP,可以叫你P兄么 (2)
- 啊,咋科斯╮(╯▽╰)╭ (6)
- 巨人肩上的小石子 (2)
- flash她妹flex (38)
- 项目管理 (10)
- 奥特曼,你弟Android来了 (4)
- 麻辣儿gis (0)
- maven 嘛味儿 (3)
- ws 哇塞 webservice (5)
- Oh,no!!!,NoSql (1)
- QQ他哥也是个企鹅,Linux (6)
- 姓i还是姓my 你都叫batis ibatis (3)
- 我喜欢夏天(春天旁边的那个季节)Springside (1)
- 测试! 测就测吧,没有喝(⊙o⊙) (3)
- 是晕+_+ 是浮云 还是云计算 (4)
- ExtJS 你是flex他哥还是他妹 (10)
- svg 你丫的资料真少 (3)
- 叫屁屁还是叫加加 ⊙﹏⊙ c++ (5)
- 鸟,还是只百灵鸟 BIRT (1)
- 权限管理 有权真好 是吧-_-! (1)
- SSH (2)
- 哥三儿好 (2)
- nginx (1)
- Oh (1)
- no!!! (1)
- NoSql (1)
最新评论
-
mong619226543:
谢谢
No identifier specified for entity -
akka_li:
没看懂啥意思!什么原因导致java.net.SocketExc ...
java.net.SocketException: Connection reset 问题解决方法 -
west_jing:
1L正解,<mvc:annotation-driven/ ...
<mvc:default-servlet-handler/> 导致 Controller失效 -
u010954806:
tgfhfdhdf
Spring Security 国际化文件 messages_zh_CN.properties 中文解释 -
yenshen:
我也碰到这个问题了,找了一大圈,最终问题解决了:<con ...
<mvc:default-servlet-handler/> 导致 Controller失效
In the previous tutorial, we knew How to Use Flex Build-in Print Class – FlexPrintJob. It’s simple to use. But you may face some challenges when print multiple pages. Here is why:
To start to print on a new page, you need to write a code like this:
printJob.addObject(targetComponent);
It adds your component to FlexPrintJob. But how many pages is it going to take?
The typical example is DataGrid. It might contains 1 or 1000 records. There is no way we can predetermine the size when binding with a dynamic data provider. Plus how do you know where to put the page break, like record 1-17 on page 1, 18-30 on page 2 …?
Fortunately, Flex gives you a workaround to solve DataGrid printing issue. Here is how:
Things You Need
mx.printing.FlexPrintJob
mx.printing.PrintDataGrid
Steps You Do
1. Create a FlexPrintJob Instance
var flexPrintJob: FlexPrintJob = new FlexPrintJob();
2. Start FlexPrintJob
flexPrintJob.start();
3. Create PrintDataGrid
var myPrintData:PrintDataGrid = new PrintDataGrid();
Application.application.addChild(myPrintData);
4. Set PrintDataGrid's DataProvider(from DataGrid), Width, and Height
myPrintData.dataProvider = myData.dataProvider;
myPrintData.width = printJob.pageWidth;
myPrintData.height = printJob.pageHeight;
5. Loop PrintDataGrid to Generate Multiple Print Pages
printJob.addObject(myPrintData);
while (myPrintData.validNextPage) {
myPrintData.nextPage();
printJob.addObject(myPrintData);
}
6. Print
printJob.send();
Sample Code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
initialize="init()">
<mx:Script>
<![CDATA[
import mx.printing.PrintDataGrid;
import mx.printing.FlexPrintJob;
import mx.collections.ArrayCollection;
[Bindable]
public var dataSource:ArrayCollection = new ArrayCollection();
private var totalRecords:Number = 100;
private function init():void {
for (var i:int = 1; i<=totalRecords; i++) {
var dataObject:Object = new Object();
dataObject.Name = "Name #" + i;
dataObject.Phone = "Phone #" + i;
dataObject.Address = "Address #" + i;
dataSource.addItem(dataObject);
}
}
private function doPrint():void {
var printJob:FlexPrintJob = new FlexPrintJob();
if (printJob.start()) {
var myPrintData:PrintDataGrid = new PrintDataGrid();
Application.application.addChild(myPrintData);
myPrintData.dataProvider = myData.dataProvider;
myPrintData.width = printJob.pageWidth;
myPrintData.height = printJob.pageHeight;
printJob.addObject(myPrintData);
while (myPrintData.validNextPage) {
myPrintData.nextPage();
printJob.addObject(myPrintData);
}
Application.application.removeChild(myPrintData);
printJob.send();
}
}
]]>
</mx:Script>
<mx:Panel title="Flex Tutorial - PrintDataGrid"
width="500" height="500"
horizontalCenter="0" verticalCenter="0"
horizontalAlign="center" verticalAlign="middle">
<mx:DataGrid id="myData"
dataProvider="{dataSource}"
width="400" height="400" />
<mx:Button label="Print" click="doPrint()"/>
</mx:Panel>
</mx:Application>
Conclusion
Adobe Flex provides PrintDataGrid to solve the problem of multiple pages printing. It works fine when your application mainly contains one big DataGrid.
However, life is not that simple. In many cases, you need to have a combination of different contains and controls like Canvas, VBox, HBox, Label, Text, Text Area, Image, plus DataGrid. Unfortunately, until Flex 3, Adobe has not provided any better solution beyond FlexPrintJob and PrintDataGrid.
So, is there any 3rd party solution? I have done a lot of research. Eventually it narrows down to an open source project. This leads to our next tutorial – Printing Multiple Pages using FlexReport.
source:http://flextutorial.org/2009/05/28/printing-multiple-pages-using-printdatagrid/
To start to print on a new page, you need to write a code like this:
printJob.addObject(targetComponent);
It adds your component to FlexPrintJob. But how many pages is it going to take?
The typical example is DataGrid. It might contains 1 or 1000 records. There is no way we can predetermine the size when binding with a dynamic data provider. Plus how do you know where to put the page break, like record 1-17 on page 1, 18-30 on page 2 …?
Fortunately, Flex gives you a workaround to solve DataGrid printing issue. Here is how:
Things You Need
mx.printing.FlexPrintJob
mx.printing.PrintDataGrid
Steps You Do
1. Create a FlexPrintJob Instance
var flexPrintJob: FlexPrintJob = new FlexPrintJob();
2. Start FlexPrintJob
flexPrintJob.start();
3. Create PrintDataGrid
var myPrintData:PrintDataGrid = new PrintDataGrid();
Application.application.addChild(myPrintData);
4. Set PrintDataGrid's DataProvider(from DataGrid), Width, and Height
myPrintData.dataProvider = myData.dataProvider;
myPrintData.width = printJob.pageWidth;
myPrintData.height = printJob.pageHeight;
5. Loop PrintDataGrid to Generate Multiple Print Pages
printJob.addObject(myPrintData);
while (myPrintData.validNextPage) {
myPrintData.nextPage();
printJob.addObject(myPrintData);
}
6. Print
printJob.send();
Sample Code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
initialize="init()">
<mx:Script>
<![CDATA[
import mx.printing.PrintDataGrid;
import mx.printing.FlexPrintJob;
import mx.collections.ArrayCollection;
[Bindable]
public var dataSource:ArrayCollection = new ArrayCollection();
private var totalRecords:Number = 100;
private function init():void {
for (var i:int = 1; i<=totalRecords; i++) {
var dataObject:Object = new Object();
dataObject.Name = "Name #" + i;
dataObject.Phone = "Phone #" + i;
dataObject.Address = "Address #" + i;
dataSource.addItem(dataObject);
}
}
private function doPrint():void {
var printJob:FlexPrintJob = new FlexPrintJob();
if (printJob.start()) {
var myPrintData:PrintDataGrid = new PrintDataGrid();
Application.application.addChild(myPrintData);
myPrintData.dataProvider = myData.dataProvider;
myPrintData.width = printJob.pageWidth;
myPrintData.height = printJob.pageHeight;
printJob.addObject(myPrintData);
while (myPrintData.validNextPage) {
myPrintData.nextPage();
printJob.addObject(myPrintData);
}
Application.application.removeChild(myPrintData);
printJob.send();
}
}
]]>
</mx:Script>
<mx:Panel title="Flex Tutorial - PrintDataGrid"
width="500" height="500"
horizontalCenter="0" verticalCenter="0"
horizontalAlign="center" verticalAlign="middle">
<mx:DataGrid id="myData"
dataProvider="{dataSource}"
width="400" height="400" />
<mx:Button label="Print" click="doPrint()"/>
</mx:Panel>
</mx:Application>
Conclusion
Adobe Flex provides PrintDataGrid to solve the problem of multiple pages printing. It works fine when your application mainly contains one big DataGrid.
However, life is not that simple. In many cases, you need to have a combination of different contains and controls like Canvas, VBox, HBox, Label, Text, Text Area, Image, plus DataGrid. Unfortunately, until Flex 3, Adobe has not provided any better solution beyond FlexPrintJob and PrintDataGrid.
So, is there any 3rd party solution? I have done a lot of research. Eventually it narrows down to an open source project. This leads to our next tutorial – Printing Multiple Pages using FlexReport.
source:http://flextutorial.org/2009/05/28/printing-multiple-pages-using-printdatagrid/
发表评论
-
Flex4多文件上传示例
2014-05-17 22:59 877---》Flex <?xml version=&quo ... -
FLEX 与 JSP 视图的结合开发
2014-03-26 17:08 1151FLEX 与 JSP 视图的结合开发 虽然用了flex作了视 ... -
Extjs 、Flex 组件通过事件解耦示例
2013-10-09 17:18 914Extjs 、Flex 组件通过事件解耦示例 ---》app ... -
heightChart 与extjs整合 动态生成历史曲线 和实时曲线
2012-03-05 17:09 5109heightChart 与extjs整合 动态生成历史曲线 和 ... -
flex 上传excel 导入数据库
2011-06-13 12:01 6807flex 上传excel 导入数据库 前端用flex上传ex ... -
flex 、servlet生成验证码方式
2011-05-05 14:07 1193flex 、servlet生成验证码方式 -----》fle ... -
中文命名的图片加载后 本地能显示 但放到服务器上就出不来了
2011-02-22 16:16 2709中文命名的图片加载后 本地能显示 但放到服务器上就出不来了 ... -
flex 程序减肥几种方法
2011-02-17 14:05 992flex 程序减肥几种方法 1、采用模块化管理 2、采用RS ... -
flex动态换肤的demo例子
2011-02-17 09:30 1326flex动态换肤的demo例子 ----》建立三个css样 ... -
as3的反射
2011-01-28 17:30 1249as3的反射 ------》getDefinitionByN ... -
AIR 应用: 黏贴 剪贴板中的图片
2011-01-24 11:14 1456AIR 应用: 黏贴 剪贴板中的图片 from : http: ... -
flex 权限系统研究
2011-01-12 15:59 1676f权限一般就是涉及增删改查 的操作。 思路,利用flex-s ... -
如何在左上角画图
2010-12-31 10:50 1399如何在左上角画图 我想在屏幕左上角 画一个正方形,按下面的代码 ... -
类似javadoc功能的 flex asdoc
2010-12-21 10:33 1273配置过程 可以参考 http://bhsc-happy.ite ... -
Flash Builder 找不到所需的 Adobe Flash Player 调试器版本 问题解决
2010-12-15 13:28 5664Flash Builder 找不到所需的 Adobe Flas ... -
Cairngrom Demo程序撰写心得
2010-12-10 14:42 1091------》执行顺序 初始化事件与处理进行绑定组件( ... -
felx包含到jsp中去
2010-10-08 15:05 1492Jsp包含到flex中用iframe; Flex包含到jsp中 ... -
为什么定义事件用<mx:Metadata> 标签
2010-10-08 11:01 3316定义方法方式: <mx:Metadata> ... -
mate框架应用几点心得
2010-09-29 11:23 1200mate框架应用几点心得 *** new 事件的时候一定要冒 ... -
后台的返回的结果集是object类型的,不是具体对象?
2010-09-14 14:43 1427后台的返回的结果集是object类型的,不是具体对象? 解决方 ...
相关推荐
尽管PrintDataGrid不是Flex3的内置组件,但在使用PrintAdvancedDataGrid时,要注意其对分页的处理,以便实现打印时的分页效果。 对于简单的打印操作,如果没有分页和下拉框的需求,可以直接将要打印的组件或容器...
报表布局:如果要在Flex中打印页面,你应该创建一个容器,并把它加入到FlexPrintJob中。它处理静态内容时没有什么大问题。但是如果创建动态报表,即你不知道在处理过程中会产生多少页的话,事情很快会变成噩梦。 多...
Flex中有一系列内置拖放支持的控件,包括: - `DataGrid` - `HorizontalList` - `List` - `PrintDataGrid` - `TileList` - `Tree` 这些控件允许将可拖动的控件条目移动到可接收拖放的控件中。然而,如果要实现条目...
1. **Flex打印API**:Flex提供了`flash.printing.PrintJob`类来实现打印功能。开发者可以通过创建PrintJob对象,添加要打印的内容,然后调用start()方法来启动打印任务。 2. **DataGrid的复制和转换**:由于直接...
easyui快速打印datagrid内容,通过创建容纳所需要的打印内容(需要打印的表格通过方法组装成字符串放入DIV中),然后调用window.print打印;具体步骤如下:1.html页面需要有专门的DIV用于输出Dialog 2.在html页面...
在VB.NET环境中,打印DataGridView控件中的数据是一个常见的需求,特别是在报表或数据分析的应用场景中。以下将详细讲解如何实现这个功能。 首先,我们要理解DataGridView是.NET Framework提供的一种用于显示表格...
### Flex3组件拖放教程知识点总结 #### 一、关于组件拖放 拖放功能是Flex3中一种非常实用的功能,它可以实现用户界面元素的直观交互。通过拖放操作,用户能够选择一个对象(例如`List`控件或Flex中的`Image`控件)...
可以打印datagridview的类 调用方法: PrintDataGridView printDataGrid = new PrintDataGridView(); printDataGrid.PrintDatagridView(dataGridView1, true);
最后,关于提供的文件"PrintDataGrid.sln"和"PrintDataGrid",它们很可能是一个示例解决方案和项目文件,包含了实现上述功能的代码。通过打开和分析这些文件,你可以直接看到如何在实际项目中应用这些概念和技术。 ...
- **FlexPrintJob、PrintDataGrid**: 打印相关的组件,支持打印DataGrid等内容。 #### Validatorsandformatters(验证器与格式化器) - **Validators**: 用于验证用户输入的数据是否符合规则。 - **CreditCard...
12、删除了PrintDataGrid函数(若要打印DataGrid,请先调用ConvertDataGridToDGV函数将DataGrid转换为DataGridView再以打印DGV的形式打印)和ChartGraph图表组件(图表打印请使用功能更强大且不依赖Excel的Chartlet...
- **FlexPrintJob/PrintDataGrid** - 打印相关的组件。 - **PrintDataGridExample** - 打印数据网格的例子。 - **FormPrintView/FormPrintHeader/FormPrintFooter** - 表单打印视图及相关组件。 #### 五、验证器与...
C#中的打印功能通常依赖于.NET Framework提供的`System.Drawing.Printing`命名空间。这个命名空间包含了`PrintDocument`类,它是进行打印操作的基础。以下是一些关键步骤: 1. **创建PrintDocument对象**:首先,...
--//打印--> function CreateFormPage(strPrintName, printDatagrid) { var tableString = '<div><table width="100%">;">; font-weight:bold;">;"> 年;"> 半年广东省房屋市政工程安全生产文明施工示范工地申报...
之前有介绍过如何实现easyui里datagrid内容的打印,今天给大家介绍下如何实现datagrid内容导出为excel文件。以下为代码实现: export.js function ChangeToTable(printDatagrid) { var tableString = '...
同时,"PrintDataGrid.exe"可能是一个用于数据展示和打印的程序,配合书中的数据和结果,提供了直观的可视化工具。而"Northwind.mdb"则可能是一个包含示例数据的Access数据库文件,读者可以使用这些数据进行练习和...
1. **获取 DataGrid 的列配置**:通过 `printDatagrid.datagrid("options").frozenColumns` 和 `printDatagrid.datagrid("options").columns` 获取固定列和所有列的配置信息。 2. **构建表头**:根据列配置构建 `...