0

所以我们做得很好。

使用 FlexPrintJob 从 XMLListCollection 获取字段以在 Flash Builder 4 AIR 应用程序中打印,并使用其自己的 PrintDataGrid 自定义 PrintView 对象。

<mx:PrintDataGrid id="myDataGrid" width="100%">
    <mx:columns>
        <!-- "word" is the name of the XML field that prints-->
        <mx:DataGridColumn dataField="word" headerText="My Word List" />
    </mx:columns>
</mx:PrintDataGrid>

现在我希望能够为用户提供一个选项,以便在每个单词之前的打印输出中添加一个复选框。我应该创建另一个自定义 PrintView 吗?如何将复选框控件(仅用于打印输出,不需要在应用程序本身中)添加到列?

4

1 回答 1

0

我自己想出了一个解决方案。由于这些复选框只需要在打印页面上,它们不需要是实际的复选框控件,因此我在 labelFunction 中使用 Unicode 编号作为空白白框(actionscript 语法中的 \u25a2)。

<mx:PrintDataGrid id="myDataGrid" width="100%">
    <mx:columns>
        <mx:DataGridColumn dataField="word" headerText="My Word List" labelFunction="addCheckBoxes" />
    </mx:columns>
</mx:PrintDataGrid>
<fx:Script>
    <![CDATA[
        function addCheckBoxes(theItem:Object, theColumn:DataGridColumn):String{
            var itemText:String = theItem[theColumn.dataField];
            var retString:String = "\u25a2 \u25a2 \u25a2  " + itemText;
            return retString;
        }
    ]]>
</fx:Script>

此代码放置在我最初为列表创建的 PrintView 的副本中。

于 2012-10-10T22:38:01.910 回答