I'm having a problem with PDF exporting from RadGrid.
Basically the programmatic styles I apply to the columns and cells are not getting applied if I export using Internet Explorer. Firefox and Chrome work fine. I'm utterly at a loss as to how this happens, here is the style-specific code I use:
protected void btnExport_Click(object sender, EventArgs e) |
{ |
isExport = true; |
List_SelectedIndexChanged(new object(), new EventArgs()); //this applies a filter expression based on front end controls |
ApplyColumnSettings(); |
G1.ExportSettings.ExportOnlyData = true; |
G1.ExportSettings.OpenInNewWindow = true; |
G1.ExportSettings.FileName = "FileName"; |
G1.ExportSettings.Pdf.Title = "Title"; |
G1.ExportSettings.Pdf.Author = "Author"; |
expanded = new bool[G1.Items.Count]; |
foreach (GridDataItem i in G1.Items) |
{ |
if (i.Expanded) |
expanded[i.ItemIndex] = true; |
else |
expanded[i.ItemIndex] = false; |
} |
G1.MasterTableView.ExportToPdf(); |
} |
protected void ApplyColumnSettings() |
{ |
foreach (GridColumn col in G1.MasterTableView.Columns) |
{ |
switch (col.UniqueName) |
{ |
case "exCol": col.Visible = false; break; |
case "ExpandColumn": col.Visible = false; break; |
case "ItemNumber": col.Visible = false; break; |
case "ItemNumberLink": col.Visible = true; col.HeaderStyle.Width = Unit.Pixel(37);break; |
case "COURSE_ID": col.HeaderStyle.Width = Unit.Pixel(130); break; |
case "COURSE_TITLE": col.HeaderStyle.Width = Unit.Pixel(255); break; |
case "INSTR_NAME": col.HeaderStyle.Width = Unit.Pixel(80); break; |
case "day_CD": col.HeaderStyle.Width = Unit.Pixel(100); break; |
case "time": col.HeaderStyle.Width = Unit.Pixel(120); break; |
case "room_loc": col.HeaderStyle.Width = Unit.Pixel(130); break; |
case "BRANCH": col.HeaderStyle.Width = Unit.Pixel(100); break; |
case "type": col.HeaderStyle.Width = Unit.Pixel(70); break; |
case "SeatsLeft": col.HeaderStyle.Width = Unit.Pixel(70); break; |
case "cr": col.HeaderStyle.Width = Unit.Pixel(50); break; |
} |
} |
} |
protected void G1_ItemCreated(object sender, GridItemEventArgs e) |
{ |
if (isExport) |
ApplyPDFStyles(e.Item); |
} |
protected void ApplyPDFStyles(GridItem item) |
{ |
if (item is GridHeaderItem) |
item.Style["background-color"] = "#EEEEEE"; |
foreach (TableCell cell in item.Cells) |
cell.Style["text-align"] = "left"; |
} |
I've attached a picture showing how the header styles come out (the data fallows the same patterns), notice how the far right column gets chomped off all together...
Any ideas?