Hi,
I want to print a form with xamGrid on it (not xamDataGrid because it does not support cell merging). Since xamGrid does not support report paging, I do paging manually - scroll grid to specified row and print it using Report.Print(), where grid is used as visual report section :
(Report.Sections.Add(new EmbeddedVisualReportSection(xamGrid))
and do it page by page. I do scrolling using
xamGrid.ScrollCellIntoView(xamGrid.Rows[firstPageRow].Cells[0])
The last row of the printed grid is usually lost, only narrow top part of it is visible, something like this:
I can fix it by scrolling grid on page size - 1 between the pages.In this case sometimes I have duplicate records on two pages but not a missing row. The problem is in the last row of the last page, it always truncated at the bottom. Is it possible to fix it ?
Thanks,
Ed
Hi Ed,
I tried putting together a sample but I'm stuck on trying to figure out exactly how you are printing the XamGrid per page. At first I thought you were just doing something like this:
report.Sections.Add(new EmbeddedVisualReportSection(xamGrid)); xamGrid.ScrollCellIntoView(xamGrid.Rows[firstPageRow].Cells[0]); report.Sections.Add(new EmbeddedVisualReportSection(xamGrid)); xamGrid.ScrollCellIntoView(xamGrid.Rows[secondPageRow].Cells[0]); report.Sections.Add(new EmbeddedVisualReportSection(xamGrid)); xamGrid.ScrollCellIntoView(xamGrid.Rows[thirdPageRow].Cells[0]); report.Sections.Add(new EmbeddedVisualReportSection(xamGrid));
Where basically you add to the report, then call ScrollCellIntoView, then add the grid again, etc etc. But when I do this, my first page looks correct but all the pages after it have scrolled all the way to the bottom rather than gradually scrolling down. It seems like it's using the last XamGrid state for all pages but the first one.
So my question to you is, how exactly are you printing this grid? Can you post your print code for me?
Hi Rob,
I print in the loop, and inside the loop I create new Report object, initialize it, scroll the grid, set visual page section and print. Something like this:
int pageSize = getPageSize(xamGrid);
// scroll grid to the beginning //xamGrid.ScrollCellIntoView(xamGrid.Rows[0].Cells[0]);
int firstPageRow = 0;
while (true) { // scroll to the next page xamGrid.ScrollCellIntoView(xamGrid.Rows[firstPageRow].Cells[0]);
// print corresponding page in a separate report Report objReport = new Report(); ReportProgressControl progress = new ReportProgressControl(); objReport.PageHeaderTemplate = HeaderTemplate; objReport.PageFooterTemplate = FooterTemplate; objReport.ReportSettings.Margin = new Thickness(MARGIN, MARGIN, MARGIN, MARGIN); objReport.ReportSettings.HorizontalPaginationMode = HorizontalPaginationMode.Scale;objReport.ReportSettings.PageOrientation = orientation;
objReport.Sections.Add(new EmbeddedVisualReportSection(xamGrid));
objReport.ReportSettings.RepeatType = RepeatType.PageBreak; objReport.PageHeader = header; progress.Report = objReport;
objReport.Print(showPrintDialog, showProgressBar);
if (xamGrid.Rows[xamGrid.Rows.Count - 1].Cells[0].Control != null) // last page - last grid row is visible { break; }
firstPageRow = Math.Min(firstPageRow + pageSize + (pageSize-2), xamGrid.Rows.Count - 1); }