For my CommandSim project, we have a new Flex application in a late alpha stage that requires multipage DataGrid printing. Of course I am using PrintDataGrid, but as I am finding out around the Internet, Flex still has a way to go in making this work properly for complex forms.
In our situation, we create an ArrayCollection for the data, then set the dataProvider of the PrintDataGrid to the collection, and then have our form pull out relevant stuff in a variable-sized row. We also have a form that has a page number and header and footer things. It almost looks like it is working, but invariably the last one or two rows of the grid either get cut off or consumed. I would say it is a page size thing except the header and footer print properly, it’s just something to do with the PrintDataGrid getting overly ambitious about stuffing more rows than will fit into the page.
Therefore, I tried to change the height of the PrintDataGrid (usually it is set to fill both height and width of the page), but reducing the height results in some wacky results (1st page ok, 2nd page the whole grid offset to the left of the page — very bizarre!).
In my internet search for help, I found a bunch of complaints regarding PrintDataGrid, and two packages/components that tried to help:
1. FlexReport – Looks interesting, but they say it is for “non-critical” applications. Mine is not critical, but I need it to work! I tried their example, and it looked good in the preview pane but didn’t print out correctly on my printer. I thought maybe it was sized for A4 paper, so I tried printing like that, but I didn’t get the right results. I didn’t want to mess with it further, given all the caveats in the documentation.
2. BentBit Report – This said it was going to save a lot of frustration, and it’s nice that they give you the component to try. It costs $400, but I’m all for it if it can save my rear. I really need to see more examples — they have only 1, though 3 are listed (the link is to only 1 of them). Also, the web site is not well structured, as the FAQ talks about something completely different. I contacted support yesterday through email, but have not received a response. If you’re out there, BentBit people, please let me know!
Anyway, my current thought is to try to mock-up the page using a DataGrid, then set the dataProvider of the PrintDataGrid to the dataProvider of the DataGrid — maybe my problem has to do with me trying to bind variables in the PrintDataGrid based on the info packed in from the array collection. Who knows…I will post as I continue to try things out!
I thought I would go back to basics and make a PrintDataGrid that mirrored a DataGrid exactly — just have a single column, and then stuff all the text into each row, then assign the dataProvider from the DataGrid to the PrintDataGrid. After all, that is how the included examples seem to suggest it should work. After some time, I found it was still clipping rows at the end of the page. I felt like I was almost there — I could use verticalScrollPosition to back up one row on the next page, but there was no way to change the rowCount on the current page to leave the last one off. Argh!
Anyway, as luck would have it, I made contact with the BentBit folks and we’re working something out now. Yay! I am very encouraged. Still, I’m extremely surprised that this part of Flex is so weak — hopefully it will get some attention in Flash Builder 4.