I have another problem with GridExporter that my be a restriction, a defect, or (most likely) my problem someplace.
I have a grid with 2 bands that I'm trying to export to a report. The grid displays properly with the second band layed out in Card View with "Standard Labels". I can see the initialize layout event that works ok and the initialzerow events on the grid. When I call the Exporter the BeginExport is called and on return from that I get the following exception.
2008-01-14 19:18:40,218 [10] FATAL TastingMaster.Program [(null)] - Unhandled thread exceptionSystem.NullReferenceException: Object reference not set to an instance of an object. at Infragistics.Win.UltraWinGrid.GridExportCache.DocumentColumnInfoId.GetHashCode() at System.Collections.Generic.ObjectEqualityComparer`1.GetHashCode(T obj) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at Infragistics.Win.UltraWinGrid.GridExportCache.DocumentBandInfo.BuildColumnDictionary() at Infragistics.Win.UltraWinGrid.GridExportCache.BuildReportInfoCacheForRowLayoutRow(UltraGridBand band) at Infragistics.Win.UltraWinGrid.GridExportCache.BuildReportInfoCache(UltraGridBand band) at Infragistics.Win.UltraWinGrid.GridExportCache.BuildReportInfoCache(UltraGridLayout layout) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.BeginExportInternal(UltraGridExporterHelper ultraGridExporterHelper, UltraGridLayout exportLayout, RowsCollection rows) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridExporterHelper.Infragistics.Win.UltraWinGrid.IUltraGridExporter.BeginExport(UltraGridLayout exportLayout, RowsCollection rows) at Infragistics.Win.UltraWinGrid.UltraGrid.Export(IUltraGridExporter exporter) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.Export(UltraGrid grid, ISection section) at Infragistics.Win.UltraWinGrid.DocumentExport.UltraGridDocumentExporter.Export(UltraGrid grid, Report report) at TastingMaster.TastingReport.setTasters(Report report, ISection section) in D:\TastingMaster\Source\TastingMaster\TastingMaster\Tastings\TastingReport.cs:line 1231 at TastingMaster.TastingReport.BuildReport() in D:\TastingMaster\Source\TastingMaster\TastingMaster\Tastings\TastingReport.cs:line 1606 at TastingMaster.TastingReport.Print(Boolean previewReport) in D:\TastingMaster\Source\TastingMaster\TastingMaster\Tastings\TastingReport.cs:line 688 at TastingMaster.TastingReport.Print() in D:\TastingMaster\Source\TastingMaster\TastingMaster\Tastings\TastingReport.cs:line 737 at TastingMaster.TastingsReportForm.publishToolbarsManager_ToolClick(Object sender, ToolClickEventArgs e) in D:\TastingMaster\Source\TastingMaster\TastingMaster\Tastings\TastingsReportForm.cs:line 645 at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.OnToolClick(ToolClickEventArgs e) at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.FireEvent(ToolbarEventIds id, EventArgs e) at Infragistics.Win.UltraWinToolbars.ToolBase.OnToolClick() at Infragistics.Win.UltraWinToolbars.ButtonToolUIElement.DoClickProcessing(MouseEventArgs e) at Infragistics.Win.UltraWinToolbars.ButtonToolUIElement.OnMouseUp(MouseEventArgs e) at Infragistics.Win.ControlUIElementBase.ProcessMouseUpHelper(Object sender, MouseEventArgs e) at Infragistics.Win.ControlUIElementBase.ProcessMouseUp(Object sender, MouseEventArgs e) at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e) at Infragistics.Win.UltraControlBase.OnMouseUp(MouseEventArgs e) at Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
If (in the grid initializelayout event I hide the 2nd band then the export works as expected (without the extra band data of course).
Is there something in this exception that would give me a clue as to what is ok with display and not ok with exporting? Can bands in card view be exported?
An Update, more confused
So I've been playing with this problem and found the following.
The band that I'm having problems with is a simple Address band (address1, 2, city, state, etc.). In my InitializeLayout handler I added code to hide various columns as in
foreach (UltraGridColumn column in e.Layout.Bands["Detail"].Columns ) { if (!column.Hidden) { if ((column.Key == "Street1") || (column.Key == "Street2") || (column.Key == "Zip") || (column.Key == "City") ) column.Hidden = false; else column.Hidden = true; } }
What I found was that if I include 2 items from this list, any 2 items then the export works without throwing an exception. If I add a 3rd item (so any combination of 3 items) I get the exception above. So any combination of 2 items works and any combination of 3 or more fails with this exception.
Something magic about 2 ?
Thanks for the help
Neil
Hi Neil,
Yes, that's the same issue. Even if the "gap" is on the right edge of the row, it doesn't matter.
Instead of changing your existing columns to fill the gaps, you could add unbound columns to do it. You don't even have to add them to the on-screen grid. You could handle the BeginExport event on the UltraGridDocumentExporter and add some unbound columns to the layout passed in to the event.
Or just wait for the fix, of course.
Never mind my response above. I changed my layout for printing so that all the space is filled (no blank space) and I see that this is exactly what you were referring to as "gaps". The export works properly (not exactly the layout I want but something I can work with).
Thanks for the help.
Ok, Thanks.
I assume that this was found from the sample I sent. I'll have to check the layout but I don't think that there are gaps. There are lots of columns in the data source that are hidden (or being hidden) in the grid based on specific values. The layout does have ragid right edges where one the total row layout does not exactly fill a rectangle but there are not any gaps between cells. Is that the same thing?
For example. The layout looks something like
<-----------------Text ----------------><--------Text--------><-----Text----->
<------------------------- Text ------------------->
<------------Text------------->
<--------------Text--------------><-------------------Text---------------->
Is this the type of layout that you are referrring to here as "gaps"
Thanks
It looks like this can occur if your grid is using RowLayouts and there is an empty space in the layout of a row. In other words, if there is a place in the row layout where there is no column and the grid background shows through the row. Is that the case in your application?
If so, you could work around it by creating a dummy column to fill in the gap.
This will be fixed in the next hot fix.
I think I'm running the latest (1043) and I did try changing from cardview to a standard view but still using layout with no luck. I've submitted a problem report, thanks