如何使用 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?

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

问题描述

这是我第一次在这里提问,因为我的问题在 adobe flex 论坛中无法回答.所以至少最后,我来这里管理它.

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.

好吧,我猜现在每个人都在使用 Flex 4.5+,所以我问了这个问题,因为我还没有找到同时使用 spark datagrid 和 mx printdatagrid 组件.

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.

我想要实现的是打印我的 spark 数据网格中的所有数据.因此,当我进行研究时,我们使用 PrintJob 或 FlexPrintJob 类.它工作正常,但是当我需要打印多页时,因为我的火花数据网格上的数据很长,我无法以某种方式找到如何做到这一点.打印输出仅达到我的火花数据网格的高度.所以在我的研究中,他们以某种方式设法使用 mx:PrintDataGrid 组件.但遗憾的是,他们也用 mx:DataGrid 做到了.现在我的问题来了 - 如何将 mx:PrintDataGrid 与 s:DataGrid 一起使用.

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);
}  

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

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?

非常感谢.

-泰德

推荐答案

尝试这样的想法(对我有用)

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;
    tmpColumns.push(tmpColumn);

}

printGrid.columns = tmpColumns;

现在我必须找到方法,如何使用 ItemRender.我的 dataprovider 有更大的对象,我必须解析它以在网格中显示正确的数据.我必须为打印做同样的事情.

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天全站免登陆