Hello,
I'm extremely new to Infragistics products and would appreciate any help you all can give me. I created this extremely skinnied down version of what I'm trying to do in order to figure out this problem that I'm having with column groups. All I'm trying to do is display a city and employee counts with a column group over the latter. It works perfectly onscreen (Sreeen shot attached), but when I try to export the results to Excel or as a PDF the column group disapears. I've been searching for the past few days for a resolution to this, but it appears that I'm SOL. Any suggestions on how to get around this would be greatly appreciated. Note: It appears that I'm using the 2008 version (exact version number is 8.3.20083.1009)
Screenshot of the grid in the browser (looks good)
The excel screenshot (Note the missing column group)
and the PDF screenshot (again note the missing column group)
Pertinent Code from the ASPX page
<asp:Label ID="lblExport" AssociatedControlID="ddlExport" Text="Export Options" runat="server"></asp:Label>
<asp:DropDownList ID="ddlExport" runat="server"></asp:DropDownList>
<asp:Button ID="btnExport" OnCommand="btnExport_Command" Text="Export" runat="server"/>
</div>
<div id="divPersonnelContainer" runat="server" class="dashboardContainer">
<div class="dashboardContainerHeader"><%-- need to do this, because it doesn't appear that you can have a table caption on the grid --%>
<asp:Label runat="server" Text="Personnel" ID="lblPersonellDiv"></asp:Label>
<div id="divExportOptions" class="dashboardDivExport" runat="server">
<igtbl:UltraWebGrid ID="uwgDashboardPersonnel" DisplayLayout-ScrollBar="Auto" DisplayLayout-ScrollBarView="Vertical" OnInitializeLayout="uwgDashboardPersonnel_InitializeLayout" Width="97%" runat="server" DisplayLayout-AutoGenerateColumns="false" Height="250px">
<Bands>
<igtbl:UltraGridBand>
<Columns>
<igtbl:UltraGridColumn BaseColumnName="City" Key="City">
<Header Caption="City">
<RowLayoutColumnInfo OriginX="0"></RowLayoutColumnInfo>
</Header>
</igtbl:UltraGridColumn>
<igtbl:UltraGridColumn BaseColumnName="Here" Key="Here">
<Header Caption="Here">
<RowLayoutColumnInfo OriginX="1"></RowLayoutColumnInfo>
<CellStyle HorizontalAlign="Center"></CellStyle>
<igtbl:UltraGridColumn BaseColumnName="Away" Key="Away">
<Header Caption="Away">
<RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo>
</Columns>
<RowAlternateStyle BackColor="LightGray"></RowAlternateStyle>
</igtbl:UltraGridBand>
</Bands>
<DisplayLayout AllowColSizingDefault="Free" BorderCollapseDefault="Collapse" RowHeightDefault="20px" ColWidthDefault="10%" RowSelectorsDefault="No" SelectTypeRowDefault="Extended" ViewType="Flat" Section508Compliant="true" StationaryMargins="Header" Version="4.00" GroupByBox-BandLabelStyle-VerticalAlign="Top">
<HeaderStyleDefault BackColor="#637EA7" BorderStyle="Solid" HorizontalAlign="Center" ForeColor="White" Font-Bold="False" Font-Size="8" Wrap="True" Height="15">
<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" />
</HeaderStyleDefault>
<Pager AllowPaging="false"></Pager>
<FrameStyle BackColor="Window" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px" Font-Names="Microsoft Sans Serif" Font-Size="8.25pt" Height="50%" Wrap="true">
</FrameStyle>
<RowStyleDefault BackColor="white" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" Font-Size="8pt">
<BorderDetails ColorLeft="Window" ColorTop="Window" />
</RowStyleDefault>
</DisplayLayout>
</
igtbl:UltraWebGrid>
Pertinent code from the the code behind
protected void PersonnelMain_Show() --This is called from Page_Load
{
uwgDashboardPersonnel.DataSource = oFillData.getDashboardMainPersonnelInfo();
uwgDashboardPersonnel.DataBind();
}
protected void uwgDashboardPersonnel_InitializeLayout(object sender, LayoutEventArgs e)
foreach (Infragistics.WebUI.UltraWebGrid.UltraGridColumn c in e.Layout.Bands[0].Columns)
c.Header.RowLayoutColumnInfo.OriginY = 1;// Move the existing headers down a row
// now add an unbound headers
Infragistics.WebUI.UltraWebGrid.ColumnHeader chSpacerBeg =
new Infragistics.WebUI.UltraWebGrid.ColumnHeader(true);// now add a spacer to push the Employee status header over by a column
Infragistics.WebUI.UltraWebGrid.ColumnHeader chEs =
new Infragistics.WebUI.UltraWebGrid.ColumnHeader(true);
chEs.Caption =
"Employee Status";
// set the origin for the unbound column headers to be the first row of the header
chSpacerBeg .RowLayoutColumnInfo.OriginY = 0;
chEs.RowLayoutColumnInfo.OriginY = 0;
// extend the newly added headers over subColumns
chSpacerBeg.RowLayoutColumnInfo.OriginX = 0;
chSpacerBeg.RowLayoutColumnInfo.SpanX = 1;
chEs.RowLayoutColumnInfo.OriginX = 3;
chEs.RowLayoutColumnInfo.SpanX = 2;
// add the unbound headers into the header layout
e.Layout.Bands[0].HeaderLayout.Add(chSpacerBeg);
e.Layout.Bands[0].HeaderLayout.Add(chEs);
protected
void btnExport_Command(object sender, CommandEventArgs e)// fired when the export button is clicked
Infragistics.WebUI.UltraWebGrid.UltraWebGrid uwgExportGrid =
new
UltraWebGrid();// create a grid to that will be ouput. There will be multiple grids on this page and I want them all to use this method. Seems to work fine and I don't think it's the cause of my problems
if (e.CommandName == "PersonnelMain")
sExportFormat = ddlExport.SelectedValue;
PersonnelMain_Show();
uwgExportGrid = uwgDashboardPersonnel;
sReportName =
"Personnel Counts"
;
if (sExportFormat == "xls")
Workbook wbk =
new Workbook(); // Create a new Work book
Infragistics.WebUI.UltraWebGrid.ExcelExport.UltraWebGridExcelExporter UltraWebGridExcelExporter1 = new Infragistics.WebUI.UltraWebGrid.ExcelExport.UltraWebGridExcelExporter();
wbk.Worksheets.Add(sReportName);
// Add a Worksheet to the workbook
wbk.WindowOptions.SelectedWorksheet = wbk.Worksheets[sReportName];
// Make the newly added worksheet active
UltraWebGridExcelExporter1.Export(uwgExportGrid, wbk); //Export the grid to the workbook
MemoryStream stream = new MemoryStream();//Instantiate the stream class
wbk.Save(stream);//save the stream into our newly created workbook
Byte[] bytearray = (Byte[])Array.CreateInstance(typeof(byte), stream.Length);// Create an Byte[] to contain the stream
stream.Position = 0;
// Start the stream at position 0
stream.Read(bytearray, 0, (int)stream.Length); // Read the stream into the Byte[]stream.Close(); // Close the stream
Response.Clear();
// Clear the Response Object
Response.AddHeader(
"content-disposition", "attachment; filename=" + sReportName + ".xls"); // set the Content Header
Response.BinaryWrite(bytearray);
// Write the Byte[] to the output stream
Response.End();
// End the Response
else if (sExportFormat == "pdf")
Report rpt =
new Report();
ISection s1 = rpt.AddSection();//Add a section to the report
s1.PageOrientation = PageOrientation.Landscape;
UltraWebGridDocumentExporter.Export(uwgExportGrid,s1);//Export the grid to the report section
"Content-Disposition", "attachment; filename=" + sReportName + ".pdf");
"Content-Transfer-Encoding", "binary");
rpt.Publish(Response.OutputStream, FileFormat.PDF);
Response.Flush();
I assume you are both referring to the exporter for the UltraWebGrid. I'm not sure what is up with that. The exporters for the WebDataGrid will export mulit column headers (using GroupField) in 11.2 when the group field was introduced. I did run into some problems when this was implemented in the PDF engine. You have to be sure to add as many columns as you want total to the grid you are adding the cells to. So say you want a cell of col span 3 and another of 2. You'll need to add 5 columns to the table that holds those cells.
regards,David Young
I have the same issue. I tried to add new rows to mimic the header behavior with merged cells using RowSpan and ColSpan for the cells, but DocumentExporter completely ignores the rowspan and colspan's set for cells.
If the merged header layouts were automatically recogonized by the DocumentExporter, it would be ideal. Is there any round-about way or hack to get this behavior until this feature is available?