所以我有一个带有 XMLListCollection 作为 dataProvider 的火花列表控件
<wordRecord>
<word>duck</word>
<syllables>1</syllables>
<firstLetter>d</firstLetter>
<!--other fields-->
</wordRecord>
<wordRecord>
<word>machete</word>
<syllables>3</syllables>
<firstLetter>m</firstLetter>
<!--other fields-->
</wordRecord>
<!--more wordRecords-->
我想从<word>
字段中打印一个单词列表(基本上是一列)。我尝试创建一个自定义 PrintDataGrid,但它打印出空白。知道该怎么做吗?
(编辑:2012 年 9 月 12 日)
抱歉,应该包含更多代码。
我有一个从网络上某处改编的外部文件(“MyPrintView.mxml”):
<?xml version="1.0" encoding="utf-8"?>
<s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="500" height="300">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:PrintDataGrid id="myDataGrid" width="100%">
<mx:columns>
<mx:DataGridColumn />
</mx:columns>
</mx:PrintDataGrid>
</s:VGroup>
这里是应该执行打印的主 mxml 文件中的函数代码(外部文件和 FlexPrintJob 的必要库已被复制,“workingList”是我正在尝试的 spark 列表对象的 id打印自):
var printJob:FlexPrintJob = new FlexPrintJob();
if(printJob.start() != true) return;
var listPrintView:MyPrintView = new MyPrintView();
addElement(listPrintView);
/*Error on the following line*/
listPrintView.myDataGrid.dataProvider = workingList.dataProvider::word;
printJob.addObject(listPrintView);
printJob.send();
removeElement(listPrintView);
我得到的是一个空白的行列,没有打印的单词。Flash Builder 4 给我一个错误,内容如下:
"Multiple markers at this line:
-1120: Access of undefined property dataProvider.
-listPrintView"