I'm having a bear of a time getting the grid to display properly online and in print.
Does anyone have examples of an accessible, CSS-driven ultrawebgrid layout that uses % for column and FrameStyle widths along with an associated print stylesheet?
--Andrea
Hi Tony,
If I publish the UltraWebGrid Report after filtering the grid it prints only 50 records in 2 pages whereas after filtering the grid there should be 34 pages with 30 rows per page. If I publish the report without using grid filteration it prints perfectly.
Here is my code for printing:
On ImageButton click event i call the following function:
public void ProcCreateReport(UltraWebGrid theGrid, HttpResponse theResponse, bool openInline) { //try //{ Report theReport = new Report(); Infragistics.Documents.Report.Section.ISection theSection = theReport.AddSection(); //Table Pattern (think of this as a kind of "Style Sheet" for ITable //to add page numbers theSection.PageNumbering.SkipFirst = false; theSection.PageNumbering.OffsetY = -18; theSection.PageNumbering.Template = "Page [Page #] of [TotalPages]"; //Add headertext ISectionHeader s1header = theSection.AddHeader(); s1header.Height = 20; s1header.Repeat = true; IText s1headertitle = s1header.AddText(0, 0); Infragistics.Documents.Report.Text.Style bluelink = new Infragistics.Documents.Report.Text.Style(new Font("Aria", 10), Brushes.Black); s1headertitle.AddContent("Activities For Specific Period", bluelink); s1headertitle.Alignment = TextAlignment.Center; //s1headertitle.AddLineBreak(); IText s1headertimestamp = s1header.AddText(0, 0); s1headertimestamp.AddContent("Printed On: ", bluelink); s1headertimestamp.AddDateTime("dd/MM/yyyy", bluelink); s1headertimestamp.Alignment = TextAlignment.Right; //s1headertimestamp.AddLineBreak(); // Add a caption with some more information ReportText.IText caption = theSection.AddText(); ReportText.Style captionStyle = new ReportText.Style(new Infragistics.Documents.Graphics.Font("Tahoma", 9), Infragistics.Documents.Graphics.Brushes.Black); caption.AddContent("Buyer:", captionStyle); caption.AddLineBreak(); caption.AddContent("Merchandiser:", captionStyle); caption.AddLineBreak(); caption.AddContent("User:", captionStyle); caption.AddLineBreak(); caption.AddContent("Season:", captionStyle); caption.AddLineBreak(); caption.Margins.Bottom = 12; Infragistics.Documents.Report.Table.TablePattern theTablePattern = new Infragistics.Documents.Report.Table.TablePattern(); theTablePattern.Header.Repeat = true; theTablePattern.Header.Cell.Background = new Background(Infragistics.Documents.Graphics.Brushes.WhiteSmoke); theTablePattern.Row.Cell.Background = new Background(Infragistics.Documents.Graphics.Brushes.White); Infragistics.Documents.Report.Table.ITable theTable = theSection.AddTable(); theSection.PageMargins = new Margins(20f); theTable.ApplyPattern(theTablePattern); Infragistics.Documents.Report.Table.ITableCell theHeaderCell = null; Infragistics.Documents.Report.Text.IText theHeaderText = null; //Iterate through the Grid Cols and create corresponding headers in the ITable foreach (UltraGridColumn c in theGrid.Columns) { theHeaderCell = theTable.Header.AddCell(); theHeaderText = theHeaderCell.AddText(); theHeaderText.Style.Brush = new Infragistics.Documents.Graphics.SolidColorBrush(Infragistics.Documents.Graphics.Colors.Black); theHeaderText.Style.Font = new Infragistics.Documents.Graphics.Font("Tahoma", 6, FontStyle.Bold); theHeaderText.AddContent(c.Header.Caption); } Infragistics.Documents.Report.Table.ITableRow theRow = null; Infragistics.Documents.Report.Table.ITableCell theRowCell = null; Infragistics.Documents.Report.Text.IText theRowText = null; //Now create your rows: for (int r = 0; r < (theGrid.Rows.Count); r++) { theRow = theTable.AddRow(); foreach (UltraGridColumn c in theGrid.Columns) { theRowCell = theRow.AddCell(); theRowText = theRowCell.AddText(); theRowText.Style.Brush = new Infragistics.Documents.Graphics.SolidColorBrush(Infragistics.Documents.Graphics.Colors.Black); theRowText.Style.Font = new Infragistics.Documents.Graphics.Font("Tahoma", 6); if (theGrid.Rows[r].Cells.FromKey(c.Key).Value != null) { if ((c.Key == "Completion Target(%)") || (c.Key == "Actual Status(%)")) { //theRowCell.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Middle; theRowText.Alignment.Horizontal = Infragistics.Documents.Report.Alignment.Center; } if ((c.Key == "Target Date") || (c.Key == "Revise Date") || (c.Key == "Actual Date")) { if (theGrid.Rows[r].Cells.FromKey(c.Key).ToString() != "") { theRowText.AddContent(objCommonFunction.FuncGetDateFormat(theGrid.Rows[r].Cells.FromKey(c.Key).ToString())); } } else { theRowText.AddContent(theGrid.Rows[r].Cells.FromKey(c.Key).ToString()); } } } theRowText.AddLineBreak(); } //Set up the response for publishing the Report: theResponse.ContentType = "application/pdf"; if (openInline) { //Opens in Browser Itself. theResponse.AddHeader("content-disposition", "inline; filename=Document.pdf"); } else { //Prompts user for a file download. theResponse.AddHeader("content-disposition", "attachment; filename=Document.pdf"); } //Write out to the response.Output Stream and you are done. theReport.Publish(theResponse.OutputStream, FileFormat.PDF); theResponse.Flush(); theResponse.End(); //} //catch (Exception ex) //{ // Response.Write(ex.Message); //} }
Kindly suggest any soln...Its urgent..
Hi Junaid,
The WebGrid doesn't have the 'smarts' to accomplish this task. The grid will automatically stretch to fit all of the content so that data doesn't get clipped, but printing support for a browser is terribly primitive. I would recommend if you're looking to take this level of control over printing, you use the Infragistics DocumentEngine to construct a PDF document. Using the api's for the DocumentEngine, you will have much more control over how each page looks, and how big the contents are. In the end though, the majority of the work will be figuring out how to lay everything out.
Hope this helps,
-Tony
Hi,
I wanted to print the ultrawebgrid on a paper. I wanted to print the column names on all the pages. I also wanted to wrap the text in each row of the grid so that the data(if there are many coumns in the grid or change the font size) fits on a page on a landscape or portrait mode. I need the code to accomplish this.
Thanks,
Junaid.
Hi Regan,
Not sure which version you're using, but back in 2006 if I recall, we added a new Grid.DisplayLayout.ReadOnlyMode for printing support. Toggling the ReadOnlyMode to printerfriendly (level 4 I think) should fix the problem. We also later made changes to the default grid styles to enable better printing support without even setting the readonly mode. I think that fix came at some point in 2007. What ever release you're on, you may want to test it with the latest hotfix and see if that resolves the problem.
Regards,
Hi
i have a problem in export the ultarwebgrid to pdf. I have to display the lines between the columns. i tried applying the style and also by setting the border color. but i dont get the lines . Below is my code for the ultrawebgrid
<igtbl:UltraWebGrid ID="UltraWebGrid1" runat="server" Width="100%" Height="212px">
<DisplayLayout AllowColSizingDefault="Free" HeaderStyleDefault-BackgroundImage="Images/header.jpg"
AutoGenerateColumns="true" BorderCollapseDefault="Separate" Name="igGridTwo"
RowHeightDefault="20px" StationaryMargins="Header" StationaryMarginsOutlookGroupBy="True"
TableLayout="Fixed" Version="4.00" ViewType="Hierarchical" AllowRowNumberingDefault="ByDataIsland">
<FrameStyle Width="100%" Height="95%">
</FrameStyle>
<Pager AllowPaging="True" PageSize="20" Alignment="Left" PagerAppearance="Both">
</Pager>
<RowStyleDefault Font-Names="Verdana" Font-Size="8pt">
</RowStyleDefault>
<ActivationObject BorderColor="" BorderWidth="">
</ActivationObject>
<RowAlternateStyleDefault >
</RowAlternateStyleDefault>
<RowSelectorStyleDefault >
</RowSelectorStyleDefault>
</DisplayLayout>
<Bands>
<igtbl:UltraGridBand>
<AddNewRow View="NotSet" Visible="NotSet">
</AddNewRow>
</igtbl:UltraGridBand>
</Bands>
</igtbl:UltraWebGrid>
.Columns(1).CellStyle.HorizontalAlign = HorizontalAlign.Left
.Columns(1).CellStyle.VerticalAlign = VerticalAlign.Middle
.Columns(1).CellStyle.BorderColor = Drawing.Color.AliceBlue
End With
Can anybody tell em how do i get the vertical lines to be displayed in the PDF as well as in the grid. i am using the documentexporter.
i have also tried setting the border color in the initialize row of the documentexporter.