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

[Solved] header not showing in exporttopdf

3 Answers 214 Views
Grid
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 19 Mar 2009, 12:44 AM
I have a grid inside the nestedviewtemplate of another grid.

In the commanditemtemplate i have a button for exporting the grid.

However, my header row is not displayed. I am unable to figure out why my header is not visible.

Grid declaration:

<

NestedViewTemplate>

 

 

 

 

<telerik:RadGrid ID="RadGridKeyRelation" runat="server" Visible="false" AllowPaging="true"

 

 

AllowFilteringByColumn="true" OnInit="RadGridKeyRelation_Init" OnNeedDataSource="RadGridKeyRelation_NeedDataSource" OnItemDataBound="RadGridKeyRelation_ItemDataBound"

 

 

Width="950px" AutoGenerateColumns="false" OnItemCommand="RadGridKeyRelation_ItemCommand" OnItemCreated="RadGridKeyRelation_ItemCreated" EnableLinqExpressions="false" PageSize="10" HeaderStyle-BackColor="#5297b9" HeaderStyle-BorderColor="#ffffff">

 

 

<ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="false"

 

 

FileName="RelatedContactsExport">

 

 

<Pdf AllowAdd="false" AllowCopy="true" AllowModify="true" AllowPrinting="true" Author="Anonymous"

 

 

Keywords="None" PageBottomMargin="0.5in" PageLeftMargin="0.5in" PageRightMargin="0.5in" PageWidth="425mm"

 

 

PageTopMargin="0.5in" PageTitle="Grid export document" Subject="Grid Export" Title="Grid export"

 

 

PaperSize="Letter" />

 

 

</ExportSettings>

 

 

<MasterTableView TableLayout="Fixed" Name="KeyRelations" DataKeyNames="RelatedContactID, LastName, FirstName"

 

 

CommandItemDisplay="Top">

 

 

<Columns>

 

 

<telerik:GridTemplateColumn HeaderText="Name" UniqueName="KeyRelName" HeaderStyle-Width="20%"

 

 

FilterControlWidth="140px" DataField="LastName" CurrentFilterFunction="StartsWith"

 

 

ItemStyle-BackColor="#eef6f9" AutoPostBackOnFilter="true">

 

 

<ItemTemplate>

 

 

<br />

 

 

<asp:LinkButton ID="LinkButtonSpouseName" CssClass="linkButton" CommandName="ShowContact"

 

 

runat="server"><b><%# Eval("Name")%></b></asp:LinkButton>

 

 

<asp:Label ID="Label1" runat="server" CssClass="label" Visible='<%# !Convert.IsDBNull(Eval("Relationship")) %>'><br /><b>Relationship</b>:&nbsp;</asp:Label><%# Eval("Relationship")%>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Type" UniqueName="Type" HeaderStyle-Width="10%"

 

 

ItemStyle-BackColor="#eef6f9" DataField="RelationType">

 

 

<FilterTemplate>

 

 

<telerik:RadComboBox ID="RadComboBoxRelatedContacts" runat="server" AutoPostBack="true"

 

 

OnPreRender="RadComboBoxRelatedContacts_PreRender" Width="95px" OnSelectedIndexChanged="RadComboBoxRelatedContacts_SelectedIndexChanged">

 

 

<Items>

 

 

<telerik:RadComboBoxItem Text="Family" Value="Family" />

 

 

<telerik:RadComboBoxItem Text="Business" Value="Business" />

 

 

<telerik:RadComboBoxItem Text="Personal" Value="Personal" />

 

 

<telerik:RadComboBoxItem Text="Professional" Value="Professional" />

 

 

<telerik:RadComboBoxItem Text="Colleagues" Value="Colleagues" />

 

 

</Items>

 

 

</telerik:RadComboBox>

 

 

</FilterTemplate>

 

 

<ItemTemplate>

 

<%

# Eval("RelationType")%>&nbsp;

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Phone" UniqueName="Phone" HeaderStyle-Width="21%"

 

 

ItemStyle-BackColor="#eef6f9" AllowFiltering="false">

 

 

<ItemTemplate>

 

<%

# Eval("Phone")%>&nbsp;

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Remarks" UniqueName="Remarks" HeaderStyle-Width="10%"

 

 

ItemStyle-BackColor="#eef6f9" FilterControlWidth="75px" DataField="Remarks" AllowFiltering="false">

 

 

<ItemTemplate>

 

<%

# Eval("Remarks")%>&nbsp;

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

</Columns>

 

 

<CommandItemTemplate>

 

 

<asp:LinkButton ID="LinkButtonExportKeyRel" runat="server" CommandName="Export" OnClick="LinkGridRelatedContactPrint_OnClick"

 

 

CausesValidation="false" Text="Export" ForeColor="Black"></asp:LinkButton>&nbsp;

 

 

</CommandItemTemplate>

 

 

<PagerStyle Position="TopAndBottom" PrevPageText="Prev" NextPageText="Next" />

 

 

</MasterTableView>

 

 

</telerik:RadGrid>

 



.cs code for export

protected

void LinkGridRelatedContactPrint_OnClick(object sender, EventArgs e)

 

{

 

foreach (GridNestedViewItem item in RadGridContact.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.NestedView))

 

{

 

RadGrid gridKeyRel = (RadGrid)item.FindControl("RadGridKeyRelation"); 

 

gridKeyRel.Rebind();

FormatGridExport(gridKeyRel);

 

gridKeyRel.MasterTableView.ExportToPdf();

}

}


I am also unable to put any formatting on the pdf export.

 

private

void FormatGridExport(RadGrid grid)

 

{

 

foreach(GridHeaderItem headerItem in grid.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.Header))

 

{

 

 

headerItem.Style[

"font-size"] = "6pt";

 

headerItem.Style[

"color"] = "#ffffff";

 

headerItem.Style[

"background-color"] = "#003e7e";
headerItem.Style["vertical-align"] = "middle";

 

 

foreach (TableCell cell in headerItem.Cells)

 

{

cell.Style[

"font-family"] = "Tahoma";

 

cell.Style[

"text-align"] = "center";

 

cell.Style[

"font-weight"] = "normal";

 

cell.Style[

"border-color"] = "#003e7e";

 

}

 

}

 

foreach (Telerik.Web.UI.GridItem dataItem in grid.MasterTableView.GetItems(Telerik.Web.UI.GridItemType.Item))

 

{

 

 

foreach (TableCell cell in dataItem.Cells)

 

{

cell.Style[

"font-family"] = "Tahoma";

 

cell.Style[

"text-align"] = "center";

 

cell.Style[

"color"] = "#898a8c";

 

cell.Style[

"font-size"] = "5.5pt";}

 

}

}

What am I doing wrong here?

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 24 Mar 2009, 01:51 PM
Hello Anumeha,

Unfortunately I could not reproduce this issue. I created a test project in my attempt to recreate the abnormality explained so far. I used the latest official build of RadControls. I've attached my sample web site project to this forum thread. Please examine it and tell me if I am missing something.

Regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
John John
Top achievements
Rank 1
answered on 12 Feb 2010, 07:30 AM
HI newbie..
  I am looking for the anwer of exporting nested grid to pdf file. I also would like to know the concept of applying styles to PDF file. So how we can achieve the scenario.

-Thanks
0
Daniel
Telerik team
answered on 17 Feb 2010, 04:58 PM
Hello John,

Please stick to this forum thread:
Link to public post

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
newbie
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
John John
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or