如何使用mx PrintDataGrid打印flex spark datagrid?或者有没有其他方法来实现这一点,而不使用mx PrintDataGrid? [英] How to print flex spark datagrid by using the mx PrintDataGrid? Or is there other way to achieve this without using the mx PrintDataGrid?

查看:261
本文介绍了如何使用mx PrintDataGrid打印flex spark datagrid?或者有没有其他方法来实现这一点,而不使用mx PrintDataGrid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次问这个问题,因为我的问题在adobe flex论坛上是不负责的。所以至少最后,我来管理这里。



嗯,Flex 4.5+是我猜每个人现在都在工作,所以我问了这个问题,因为我避风港没有找到工作两个 spark datagrid和mx printdatagrid组件在一起



我要实现的是打印所有数据在我的火花datagrid内。所以当我进行研究时,我们使用PrintJob或FlexPrintJob类。它工作正常,但是当我需要打印多个页面,因为我的火花datagrid上的数据是相当长的,我无法找到一种方法如何做到这一点。打印输出只能到达我的火花数据网格的高度。所以在我的研究中,他们以某种方式管理它来使用mx:PrintDataGrid组件。可惜不幸的是,他们也用一个mx:DataGrid。现在这里是我的问题 - 如何使用mx:PrintDataGrid以及s:DataGrid

  var printJob:PrintJob = new PrintJob(); 

if(printJob.start())
{
var printGrid:PrintDataGrid = new PrintDataGrid();
printGrid.width = printJob.pageWidth;
printGrid.height = printJob.pageHeight;
printGrid.columns = mySparkDataGrid.columns; //这行抛出一个异常
printGrid.dataProvider = mySparkDataGrid.dataProvider;
printGrid.visible = false;
FlexGlobals.topLevelApplication.addElement(printGrid);

while(printGrid.validNextPage)
{
printGrid.nextPage();
printJob.addPage(printGrid);
}

printJob.send();
parentApplication.removeElement(printGrid);
}

所以请,这里有人可以帮助我吗?如果将spark datagrid列转换为mx datagrid列是不可能的,是否可以使用多个页面打印spark datagrid上的所有数据?



提前感谢



-Ted

解决方案



for(var i:int = 0; i< mySparkDataGrid.columns.length - 1; i ++) {



var tmpColumn:DataGridColumn = new DataGridColumn();
tmpColumn.headerText =(mySparkDataGrid.columns.getItemAt(i)为GridColumn).headerText;
tmpColumn.headerText =(mySparkDataGrid.columns.getItemAt(i)为GridColumn).headerText;
tmpColumns.push(tmpColumn);



}



printGrid.columns = tmpColumns; p>

现在我必须找到方法,如何使用ItemRender.My dataprovider有更大的对象,我必须解析它在网格中显示正确的数据。我需要做打印。


this is my first time to ask here since my question is not answerable in the adobe flex forum. So at least finally, I've come to manage it here.

Well, Flex 4.5+ is I guess everyone is working on nowadays so I asked this question since I haven't yet find working both spark datagrid and the mx printdatagrid components together.

What I'm trying to achieve is to print all the data inside my spark datagrid. So when I do my research, we use the PrintJob or the FlexPrintJob classes. It works fine but when I need to print multiple pages since the data on my spark datagrid is quite long, I can't somehow find a way how to do it. The print output is only upto where the height of my spark datagrid. So in my research, they somehow managed it to use the mx:PrintDataGrid component. But sad to say, they did it with an mx:DataGrid also. Now here comes my problem - how to use the mx:PrintDataGrid along with s:DataGrid.

var printJob:PrintJob = new PrintJob();

if (printJob.start())
{
    var printGrid:PrintDataGrid = new PrintDataGrid();
    printGrid.width = printJob.pageWidth;
    printGrid.height = printJob.pageHeight;
    printGrid.columns = mySparkDataGrid.columns; // this line throws an exception
    printGrid.dataProvider = mySparkDataGrid.dataProvider;
    printGrid.visible = false;
    FlexGlobals.topLevelApplication.addElement(printGrid);

    while (printGrid.validNextPage)
    {
        printGrid.nextPage();
        printJob.addPage(printGrid);
    }

    printJob.send();
    parentApplication.removeElement(printGrid);
}  

So please, can anyone here help me with this? If converting a spark datagrid columns to the mx datagrid columns is not possible, is there a way that I can print all the data on the spark datagrid using multiple pages?

Big thanks in advance.

-Ted

解决方案

Try somethink like this(it works to me)

for (var i:int = 0; i < mySparkDataGrid.columns.length - 1; i++) {

var tmpColumn:DataGridColumn =new DataGridColumn(); tmpColumn.headerText=(mySparkDataGrid.columns.getItemAt(i) as GridColumn).headerText; tmpColumn.headerText=(mySparkDataGrid.columns.getItemAt(i) as GridColumn).headerText; tmpColumns.push(tmpColumn);

}

printGrid.columns=tmpColumns;

Now i have to find way,how use ItemRender.My dataprovider has bigger object and I have to parse it for display correct data in grid.The same I have to do for print.

这篇关于如何使用mx PrintDataGrid打印flex spark datagrid?或者有没有其他方法来实现这一点,而不使用mx PrintDataGrid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆