This is a migrated thread and some comments may be shown as answers.

Columns not exporting to PDF

4 Answers 71 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vitaly
Top achievements
Rank 1
Vitaly asked on 23 Nov 2011, 05:14 PM
Good morning guys and happy Thanksgiving,
I have two DataGrid on my aspx page and both of them exporting to PDF.First DataGrid working without any problem but the second one header columns not exporting to pdf:

<

 

telerik:RadGrid ID="PrnHistoryGrid" runat="server"

 

 

GridLines="None" AllowPaging="true" AllowSorting="true" OnExcelMLExportRowCreated="PrnHistoryGrid_ExcelMLExportRowCreated" OnExcelMLExportStylesCreated="PrnHistoryGrid_ExcelMLExportStylesCreated" OnItemCreated="PrnHistoryGrid_ItemCreated" OnNeedDataSource="PrnHistoryGrid_NeedDataSource" OnPdfExporting="PrnHistoryGrid_PdfExporting" OnSortCommand="PrnHistoryGrid_SortCommand" >

 

 

<ExportSettings FileName="PrnHistoryData" OpenInNewWindow="true" IgnorePaging="true" ExportOnlyData="true">

 

 

<Excel Format="ExcelML" FileExtension="xls"/>

 

 

<Pdf FontType="Subset" AllowPrinting="true" PaperSize="Letter" />

 

 

</ExportSettings>

 

 

<MasterTableView AutoGenerateColumns="false" >

 

 

 

<RowIndicatorColumn>

 

 

<HeaderStyle Width="70px" />

 

 

</RowIndicatorColumn>

 

 

<ExpandCollapseColumn>

 

 

<HeaderStyle Width="70px" />

 

 

</ExpandCollapseColumn>

 

 

 

<Columns>

 

 

<telerik:GridBoundColumn HeaderText="Req No" DataField="TRKNO" UniqueName="TRKNO" ReadOnly="True" SortExpression="TRKNO" HeaderButtonType="TextButton" >

 

 

<HeaderStyle Width="3px" />

 

 

<ItemStyle Width="3px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Job" DataField="JOB" UniqueName="JOB" ReadOnly="True" SortExpression="JOB" HeaderButtonType="TextButton">

 

 

<HeaderStyle Width="3px" />

 

 

<ItemStyle Width="3px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Pgm No" DataField="PGMNO" UniqueName="PGMNO" ReadOnly="True" SortExpression="PGMNO" HeaderButtonType="TextButton" >

 

 

<HeaderStyle Width="2px" />

 

 

<ItemStyle Width="2px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Pgm loc" DataField="PGMLOC" UniqueName="PGMLOC" ReadOnly="True" SortExpression="PGMLOC" HeaderButtonType="TextButton" >

 

 

<HeaderStyle Width="5px" />

 

 

<ItemStyle Width="5px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Service StDate" DataField="STDATE" UniqueName="STDATE" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="true" SortExpression="STDATE" HeaderButtonType="TextButton">

 

 

<HeaderStyle Width="15px" />

 

 

<ItemStyle Width="15px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Service EndDate" DataField="ENDDATE" UniqueName="ENDDATE" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="true" SortExpression="ENDDATE" HeaderButtonType="TextButton">

 

 

<HeaderStyle Width="15px" />

 

 

<ItemStyle Width="15px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Req Hrs" DataField="REQHRS" UniqueName="REQHRS" ReadOnly="true" SortExpression="REQHRS" HeaderButtonType="TextButton">

 

 

<HeaderStyle Width="5px" />

 

 

<ItemStyle Width="5px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Paid Hrs" DataField="YTDHRS" UniqueName="YTDHRS" ReadOnly="true" SortExpression="YTDHRS" HeaderButtonType="TextButton">

 

 

<HeaderStyle Width="5px" />

 

 

<ItemStyle Width="5px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Paid Mins" DataField="YTDMINS" UniqueName="YTDMINS" ReadOnly="true" SortExpression="YTDMINS" HeaderButtonType="TextButton">

 

 

<HeaderStyle Width="5px" />

 

 

<ItemStyle Width="5px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Rec Stat" DataField="STATUS" UniqueName="STATUS" ReadOnly="true" SortExpression="STATUS" HeaderButtonType="TextButton" >

 

 

<HeaderStyle Width="1px" />

 

 

<ItemStyle Width="1px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Req Date" DataField="SENDDATE" UniqueName="SENDDATE" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="true" SortExpression="SENDDATE" HeaderButtonType="TextButton">

 

 

<HeaderStyle Width="15px" />

 

 

<ItemStyle Width="15px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Stat of Req" DataField="STATUSF" UniqueName="STATUSF" ReadOnly="true" SortExpression="STATUSF" HeaderButtonType="TextButton">

 

 

<HeaderStyle Width="1px" />

 

 

<ItemStyle Width="1px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Approved Date" DataField="APPRDATE" UniqueName="APPRDATE" DataFormatString="{0:MM/dd/yyyy}" ReadOnly="true" SortExpression="APPRDATE" HeaderButtonType="TextButton">

 

 

<HeaderStyle Width="10px" />

 

 

<ItemStyle Width="10px" />

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText="Approver Id" DataField="APPRNAME" UniqueName="APPRNAME" ReadOnly="true" SortExpression="APPRNAME" HeaderButtonType="TextButton" >

 

 

<HeaderStyle Width="70px" />

 

 

<ItemStyle Width="70px" />

 

 

</telerik:GridBoundColumn>

 

 

 

</Columns>

 

 

</MasterTableView>

 

 

<ClientSettings EnableRowHoverStyle="True">

 

 

</ClientSettings>

 

 

 

 

</telerik:RadGrid>

 


This is my code:

bool

 

IsExport1 = false;

 

 

protected void btnExporttoPdf1_Click(object sender, EventArgs e)

 

{

 

RadGrid HistoryGrid = (RadGrid)PrnHistoryReport.FindItemByValue("HistoryData").FindControl("PrnHistoryGrid");

 

HistoryGrid.DataSource = Session[

"PrnHistoryRecord"];

 

HistoryGrid.DataBind();

IsExport1 =

true;

 

HistoryGrid.MasterTableView.BorderStyle =

BorderStyle.None;

 

HistoryGrid.MasterTableView.GridLines =

GridLines.Vertical;

 

HistoryGrid.MasterTableView.Columns[0].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[1].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[2].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[3].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[4].HeaderStyle.Width =

Unit.Pixel(55);

 

HistoryGrid.MasterTableView.Columns[5].HeaderStyle.Width =

Unit.Pixel(55);

 

HistoryGrid.MasterTableView.Columns[6].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[7].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[8].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[9].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[10].HeaderStyle.Width =

Unit.Pixel(55);

 

HistoryGrid.MasterTableView.Columns[11].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[12].HeaderStyle.Width =

Unit.Pixel(40);

 

HistoryGrid.MasterTableView.Columns[13].HeaderStyle.Width =

Unit.Pixel(40);

 

 

HistoryGrid.MasterTableView.ExportToPdf();

 

}

Seems like data is exporting but not header columns.

Thanks so much for your help.

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Nov 2011, 05:25 AM
Hello Vitaly,

Try the following code.
C#:
protected void Export_Click(object sender, EventArgs e)
{
 RadGrid1.MasterTableView.GetColumn("TRKNO").Visible = true;
 RadGrid1.MasterTableView.GetColumn("JOB").Visible = true;
 RadGrid1.MasterTableView.GetColumn("PGMNO").Visible = true;
  . . . .
 RadGrid1.MasterTableView.ExportToPdf();
 RadGrid1.MasterTableView.Rebind();
}

-Shinu.
0
Iana Tsolova
Telerik team
answered on 24 Nov 2011, 10:08 AM
Hello,

If one would use the code provided by Shinu, you should make sure, you swap the lest two lines, e.g. Rebind() should be called before Export().
Other than this, the columns in Vitaly's grid look Visible by default. Can you confirm you are not hiding them server-side? Any additional information on your scenario might help us determine the cause of the problem. For instance a screenshot of the grid once launched in the browser and one more of the exported file, as well as any server-side code related to the grid.

All the best,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Vitaly
Top achievements
Rank 1
answered on 29 Nov 2011, 09:23 PM
Hi lana!!!
I tried to use a code provided by Shinu but it is not working.
Since I am new to Web could please more specific what else you need in order to help me.I did exactly the same thing as I did to first grid.

Thanks so much for your help.
Vitaly.
0
Iana Tsolova
Telerik team
answered on 30 Nov 2011, 10:06 AM
Hello Vitaly,

Having the provided information on mind, I can confirm that everything here is properly set up and there is no an obvious reason for the columns not to be exported. Do you have any server-side code related to the grid which is not shared here? Can you also send the screenshots I mentioned in my previous post?

Kind regards,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
General Discussions
Asked by
Vitaly
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Iana Tsolova
Telerik team
Vitaly
Top achievements
Rank 1
Share this question
or