Hi,
I've spent all day trying to get RadGrid to export to pdf with formatting, there are so many problems I can not resolve, my codes are based on : http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/pdfexport/defaultcs.aspx
Here is my ItemCreated event handler:
The major problems I have:
(1) Width does not work at all, every column has equal width on exported pdf no matter how I set them.
(2) Contents do not wrap, if the data source has columns to long to be fitted in a row, they got truncated or overlap with next column.
(3) Sometimes it simply throws exceptions if the data source has lengthy data, I suspect the data might contain html tags.
(4) How do I control the boders? I tried Style["border"] = "1px solid #000", no effects at all.
Please help
I've spent all day trying to get RadGrid to export to pdf with formatting, there are so many problems I can not resolve, my codes are based on : http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/pdfexport/defaultcs.aspx
Here is my ItemCreated event handler:
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(isPdfExport)
{
GridItem item = e.Item
as
GridItem;
switch
(item.ItemType)
//Mimic RadGrid appearance for the exported PDF file
{
case
GridItemType.Item:
item.Style[
"background-color"
] =
"#ffffff"
;
item.Style[
"font-size"
] =
"12px"
;
item.Cells[2].Style[
"width"
] =
"50px"
;
break
;
case
GridItemType.AlternatingItem:
item.Style[
"background-color"
] =
"#eeeeee"
;
item.Cells[2].Style[
"width"
] =
"50px"
;
item.Style[
"font-size"
] =
"12px"
;
break
;
case
GridItemType.Header:
for
(
int
i = 0; i < item.Cells.Count; i++)
{
item.Cells[2].Style[
"width"
] =
"50px"
;
item.Cells[i].Style[
"text-align"
] =
"left"
;
item.Cells[i].Style[
"background-color"
] =
"#010101"
;
item.Cells[i].Style[
"color"
] =
"#ffffff"
;
}
break
;
case
GridItemType.Footer:
case
GridItemType.GroupHeader:
case
GridItemType.GroupFooter:
break
;
}
}
}
(1) Width does not work at all, every column has equal width on exported pdf no matter how I set them.
(2) Contents do not wrap, if the data source has columns to long to be fitted in a row, they got truncated or overlap with next column.
(3) Sometimes it simply throws exceptions if the data source has lengthy data, I suspect the data might contain html tags.
(4) How do I control the boders? I tried Style["border"] = "1px solid #000", no effects at all.
Please help