0

So I have a spark List control with an XMLListCollection as a 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-->

and I'd like to print a list of words (essentially a single column) from just the <word> field. I tried creating a custom PrintDataGrid, but it printed out blank. Any idea how to go about this?

(edit: 9/12/2012)

Sorry, should have included more code.

I have an external file ("MyPrintView.mxml") that I adapted from somewhere on the web:

<?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>

An here is the code in the function in the main mxml file that is supposed to do the printing (the external file and the necessary libraries for FlexPrintJob have been imorted, and "workingList" is the id of the spark List Object I am trying to print from):

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

What I get is a blank lined column and no printed words. Flash Builder 4 is giving me an error that reads:

"Multiple markers at this line:
-1120: Access of undefined property dataProvider.
-listPrintView"

1 Answers1

0

Fixed it myself. the DataColumn declaration needed a dataField attribute with the name of the XML field to appear. The ItemRenderer was a wild goose chase.