It does not appear that the UltraGridPrintDocument is supporting the GroupBy presentation of an UltraGrid. The GroupBy row headings don't appear in the print preview, nor do the data columns that contain the data for the GroupBy rows appear. I would have hoped that this was a setting in the RowPropertyCategories enum of the RowProperties. Am I correct in assuming GroupBy rows are not supported by the UltraGridPrintDocument?
Yes, this is supported. I can't see any reason why printing in GroupByMode should not work.I tested it out and it works fine for me.
roy_medicomp said:The GroupBy row headings don't appear in the print preview
I'm not sure what this means. What are the "GroupBy row headings"? Are you talking about GroupByRows? Or Column headers?
roy_medicomp said:nor do the data columns that contain the data for the GroupBy rows appear
Again, I am not sure what this means. If you mean that the columns that are grouped do not show up, they don't show up in the on-screen grid by default, either. There's a property on the column for HiddenWhenGroupBy which defaults to true.
What I mean is that the groupby row headings do not show in the print preview. Here is a screen capture of a portion of the grid as well as a snapshot of a portion of the preview:
The groupby row headings should be obvious; there are two levels.
And the preview snapshot; the groupby row headings do not appear:
And this is all I do for the assignmnt:
ugGridPrintDocument.Grid =
CType(oSection.Element, UltraGrid)
I am using the UltraGridPrintDocument for the Document property of an UltraPrintPreviewControl. It does not appear that I have anything else to do. I have set the ugGridPrintDocument.RowProperties = RowPropertyCategories.All
What does your call to the Print method look like?
My guess is that you are passing in a layout that doesn't have any grouping. Or you are somehow modifying the layout in the print events.
Here is a more simple piece of code I am using to test out the UltraGridPrintPreview; the grid is the same as what I previously posted. I am not doing anything in the printing events as I did not see anything in the documenhtation that showed I needed to do any more than this. So if there is additional code, please let me know what it is.
Dim Dlg As Printing.UltraPrintPreviewDialog = New Printing.UltraPrintPreviewDialog Dim GridDoc As UltraGridPrintDocument = New UltraGridPrintDocument Try GridDoc.Grid = ugFlowSheet Dlg.Document = GridDoc Dlg.ShowDialog(Me) Dim f As New PrintDlg Catch ex As Exception PostError(ex) End Try
Hi,
I tried this out with the same code you have here and it works fine for me. The Print Preview shows the grid exactly as it is on-screen with the groupby rows.
So either something in your code is modifying the layout in some way, or this is a bug in the version you are using that has already been fixed.
I recommend that you get the latest service release: How to get the latest service release - Infragistics Community
If that doesn't help, then we will need you to create a small sample project demonstrating the problem and post it here so we can check it out.
Mike, I have uploaded a VS2008 VB project that can be used to evaluate the lack of GroupBy rows in the print preview. All you need to do is to select the load grid, choose the grid1.txt file, which will load the grid up. The print grid button dos that simplistic invocation of the printpreview dialog. Perhaps the problem I am having is because I o not set the grid into GroupBy mode in the InitializeLayout handler because I cannot do it there. I use this grid by directly loading data and control the grid schema with a DataTable that has no data rows. As soon as the grid's atasource is set to the table, the InitializLayout is called. If the grid has no data, an attempt o set the GroupBy olumns results in an error. So the grid is put into GroupBy mode after the grid is populated. But this should be no different than if a user controlled the grouping by dragging the column with the mouse to the GroupBy location. I do not allow that to be shown here as I am controlling the grouping.
Mike, That workaround was perfect. Thanks for bearing with me in this back and foth. I know the UltraGrid is quite a complex component, and I may be using it in odd ways. But the flexibility allows me to use it in many different ways.
While I am at it, no need to respond, but I wanted to say how pleased I am with the combination of the UltraPrintPreview and Thumbnail controls. The functionality in the preview control made it extremely easy for me to put together my own preview dialog where I allow the user to pick and choose many different elements to include in the report being generated. And I am using a Document to generat the report with the report pages converted to a metafile stream for use in the UltraPrintDocument. This grid, which I am using for a flow sheet, is the only element I have to separately deal with in a separate GridDocument. But I am using my same dialog that includes the preview and thumbnail controls along with my element selectors. I especially like the idea of clicking different regions of the thumbnail image to automatically move that region of the preview into view. Kudos for that.
Hi Roy,
Thanks for the sample. I was able to track this down.
When the grid prints, it creates a clone of the layout. When the layout is cloned, it''s creating a new set of bands and column and also cloning the SortedColumns collection on the band.
When it does this, it's firing off the BeforeSortChanged event as the new (cloned) columns are added to the cloned SortedColumnsCollection. I don't think the event should be firing at this point - that seems like a bug to me. But since it is firing and your code is cancelling the event, the columns do not get sorted and therefore they do not get grouped (since sorting and grouping are closely tied together).
So, I'm going to forward this thread over to Infragistics Developer Support so they can get the issue of the event firing fixed.
In the mean time, you can work around this very easily by modifying your BeforeSortChange event and bailing out if the layout is a print layout:
Private Sub ugFlowSheet_BeforeSortChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeSortChangeEventArgs) Handles ugFlowSheet.BeforeSortChange If e.Band.Layout.IsPrintLayout Then Exit Sub ' If loading the grid, allow the sorting used for GroupBy If (mbolLoading) Then Exit Sub ' Do not allow any user column sorting e.Cancel = True End Sub