flex打印操作(FlexPrintJob)還有分頁打印操作具體實現(xiàn)
更新時間:2013年04月28日 15:45:09 作者:
如果要使用分頁效果,則必須使用標(biāo)簽"PrintAdvancedDataGrid"(Flex3中的標(biāo)簽)才能夠?qū)崿F(xiàn)分頁效果,感興趣的朋友可以參考下
首先要導(dǎo)入 import mx.printing.FlexPrintJob;
import mx.printing.PrintAdvancedDataGrid;
1.使用FlexPrintJob進(jìn)行打印操作
1.如果沒有分頁和下拉框的時候
public function doPrint():void{
var printer:FlexPrintJob = new FlexPrintJob();
if(printer.start()){
printer.addObject(body);
printer.send();
}
}
這個方法即可 下面的可以使用,由于我使用的是Flex3,Flex3里面沒有標(biāo)簽“PrintDataGrid”,只有“PrintAdvancedDataGrid”。所以下面就使用(“PrintAdvancedDataGrid”,“AdvancedDataGrid ”,“DataGrid ”)這三種方式,切記上面的方式只適合于單個頁面(數(shù)據(jù)較少)且沒有下拉框
<mx:PrintAdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:PrintAdvancedDataGrid>
--------------------------------------------------------------------------------------
[/code]
<mx:AdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:AdvancedDataGrid>
[/code]
-----------------------------------------------------------------------------------------
<mx:DataGrid id="body" x="188" y="232">
<mx:columns>
<mx:DataGridColumn dataField="username"/>
<mx:DataGridColumn dataField="password"/>
</mx:columns>
</mx:DataGrid>
----------------------------------------------------------------------------------------------------------------------------------------------------------
如果要使用分頁效果,則必須使用標(biāo)簽"PrintAdvancedDataGrid"(Flex3中的標(biāo)簽)才能夠?qū)崿F(xiàn)分頁效果
private function doPrint():void{
var PrintJob:FlexPrintJob = new FlexPrintJob();
if(PrintJob.start()){
addChild(body);
//設(shè)置的打印視圖屬性
while(true){
PrintJob.addObject(body);
if(body.validNextPage){
body.nextPage();
}else{
break;
}
}
}
PrintJob.send();
}
這個方法,所對應(yīng)的標(biāo)簽是:
<mx:PrintAdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:PrintAdvancedDataGrid>
import mx.printing.PrintAdvancedDataGrid;
1.使用FlexPrintJob進(jìn)行打印操作
1.如果沒有分頁和下拉框的時候
復(fù)制代碼 代碼如下:
public function doPrint():void{
var printer:FlexPrintJob = new FlexPrintJob();
if(printer.start()){
printer.addObject(body);
printer.send();
}
}
這個方法即可 下面的可以使用,由于我使用的是Flex3,Flex3里面沒有標(biāo)簽“PrintDataGrid”,只有“PrintAdvancedDataGrid”。所以下面就使用(“PrintAdvancedDataGrid”,“AdvancedDataGrid ”,“DataGrid ”)這三種方式,切記上面的方式只適合于單個頁面(數(shù)據(jù)較少)且沒有下拉框
復(fù)制代碼 代碼如下:
<mx:PrintAdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:PrintAdvancedDataGrid>
--------------------------------------------------------------------------------------
[/code]
<mx:AdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:AdvancedDataGrid>
[/code]
-----------------------------------------------------------------------------------------
復(fù)制代碼 代碼如下:
<mx:DataGrid id="body" x="188" y="232">
<mx:columns>
<mx:DataGridColumn dataField="username"/>
<mx:DataGridColumn dataField="password"/>
</mx:columns>
</mx:DataGrid>
----------------------------------------------------------------------------------------------------------------------------------------------------------
如果要使用分頁效果,則必須使用標(biāo)簽"PrintAdvancedDataGrid"(Flex3中的標(biāo)簽)才能夠?qū)崿F(xiàn)分頁效果
復(fù)制代碼 代碼如下:
private function doPrint():void{
var PrintJob:FlexPrintJob = new FlexPrintJob();
if(PrintJob.start()){
addChild(body);
//設(shè)置的打印視圖屬性
while(true){
PrintJob.addObject(body);
if(body.validNextPage){
body.nextPage();
}else{
break;
}
}
}
PrintJob.send();
}
這個方法,所對應(yīng)的標(biāo)簽是:
復(fù)制代碼 代碼如下:
<mx:PrintAdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:PrintAdvancedDataGrid>
相關(guān)文章
Flex中的HDividedBox和VDividedBox的比較附圖
學(xué)習(xí)Flex的朋友對HDividedBox和VDividedBox并不陌生吧,下面是兩者的簡單比較,感興趣的朋友可以參考下2013-10-10Flex父子窗口相互調(diào)用實現(xiàn)思路及源碼
這篇文章主要介紹了Flex父子窗口相互調(diào)用實現(xiàn)思路及源碼,需要的朋友可以參考下2014-05-05Flex4 DataGrid中嵌入RadioButton實現(xiàn)思路及代碼
本節(jié)主要介紹了Flex4 DataGrid中嵌入RadioButton實現(xiàn)思路及代碼,需要的朋友可以參考下2014-07-07flex4 panel去掉標(biāo)題設(shè)置透明度效果代碼
首先:去掉Panel的標(biāo)題,其次:設(shè)置透明度這個說了也是啰嗦,大家都會,不過還是提一下吧,具體請祥看本文2013-05-05flex 遍歷Object對象內(nèi)容的實現(xiàn)代碼
這篇文章主要介紹了flex 遍歷Object對象內(nèi)容的實現(xiàn)代碼,需要的朋友可以參考下2014-07-07Flex 事件分發(fā)(FlexViewer事件機(jī)制)剝離過程
本節(jié)主要介紹了如何將FlexViewer里面的事件分發(fā)及監(jiān)聽事件機(jī)制剝離出來在其他項目中使用,需要的朋友可以參考下2014-07-07flex實現(xiàn)DataGrid高亮顯示數(shù)據(jù)功能的解決方案
原生的DataGrid根本無法達(dá)到所要的效果,目前一般就是來改寫原生的DataGrid,只需重新寫一個類來重寫drawRowBackground方法就可以了2013-10-10flex中event.preventDefault()方法取消事件的默認(rèn)行為
當(dāng)點擊datagrid的第一和第四項時,itemEdit事件將不起作用,許多事件都有默認(rèn)執(zhí)行的關(guān)聯(lián)行為,接下來為大家詳細(xì)介紹下,感興趣的朋友可以參考下哈2013-04-04