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,
Do you have the latest Hot Fix? I seem to vaguely recall an issue like this being fixed.
If the latest Hot Fix doesn't fix this, then it's almost certrainly a bug in the exporter. The error is occuring when the Exporter is initially building a cache of information about the grid to help in the export process, so there's really nothing you can do in your code that should cause this code to crash.
You should report this to Infragistics Developer Support:
Get Help
As a workaround, you might try turning off CardView for the second band and see if that helps. The exporter doesn't export CardView, anyway, so it couldn't hurt.