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

when exporting to PDF, table inside ItemTemplate doesn't render

1 Answer 15 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ck
Top achievements
Rank 1
ck asked on 18 Sep 2013, 02:11 PM
i have the following grid that i am trying to export to PDF
<telerik:RadGrid ID="RadGrid1" runat="server" OnItemCreated="RadGrid1_ItemCreated" OnItemCommand="RadGrid1_ItemCommand" AutoGenerateColumns="false"<br>        AllowSorting="True" CellSpacing="0" GridLines="None" ShowHeader="false"><br>        <GroupingSettings RetainGroupFootersVisibility="True" /><br>        <ClientSettings><br>            <Scrolling UseStaticHeaders="false" /><br>        </ClientSettings><br>        <MasterTableView CommandItemDisplay="Top"><br>            <CommandItemSettings ShowExportToExcelButton="false" ShowAddNewRecordButton="false" ShowRefreshButton="false" ShowExportToPdfButton="true"></CommandItemSettings><br><ItemTemplate><br>                <asp:Panel ID="ItemContainer" CssClass='<%# (((GridItem)Container).ItemType == GridItemType.Item)? "item" : "alternatingItem" %>'<br>                    runat="server"><br>                    <table class="no-border"><br>                        <tbody><br>                            <tr><br>                                <td class="catalog-item-img"><br>                                    <img id="Img1" runat="server" src='<%# ResolveUrl("~/Service.ashx?model=document&action=DOWNLOAD&currentLanguageId="+Eval("ProducedLanguage.Id")+"&Type=Cover") %>' width="150" height="200" /><br>                                </td><br>                                <td class="catalog-item"><br>                                    <h5><br>                                        <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "~/ViewPublication.aspx?id="+Eval("MasterPublication.Id")+"&tab=i&ln="+Eval("PublicationId")%>'><%#Eval("ProducedLanguage.Title") %> </asp:HyperLink><br>                                    </h5><br>                                    <p><br>                                        <strong>Language: </strong><br>                                        <asp:Label runat="server" ID="lblLanguage" Text='<%#Eval("ProducedLanguage.Language.Name") %>'></asp:Label><br>                                        - <strong>Isbn: </strong><br>                                        <asp:Label runat="server" ID="lblIsbn" Text='<%#Eval("ProducedLanguage.Isbn") %>'></asp:Label><br>                                        - <strong>Year: </strong><br>                                        <asp:Label runat="server" ID="Label3" Text='<%#Eval("Year") %>'></asp:Label><br>                                        - <strong>Pages: </strong><br>                                        <asp:Label runat="server" ID="lblPages" Text='<%#Eval("Pages") %>'></asp:Label><br>                                        <br /><br>                                        <strong>Category: </strong><br>                                        <asp:Label runat="server" ID="Label1" Text='<%#GetContentGroups(Eval("MasterPublication") as ItcPublications.Models.MasterPublication) %>'> </asp:Label><br>                                        - <strong>Sales price: </strong><br>                                        <asp:Label runat="server" ID="Label2" Text='<%#Eval("UnitPrice")+" $" %>'></asp:Label><br>                                    </p><br>                                    <div><br>                                        <asp:Label runat="server" ID="lblBlurb" Text='<%#Eval("ProducedLanguage.MarketingBlurb") %>'></asp:Label><br>                                    </div><br>                                </td><br>                            </tr><br>                        </tbody><br>                    </table><br>                </asp:Panel><br>            </ItemTemplate><br></MasterTableView><br>        <ExportSettings SuppressColumnDataFormatStrings="false" IgnorePaging="true" FileName="MostPopularPublications"><br>            <Pdf Author="ITC" Creator="ITC" Subject="Marketing Catalog" Title="Marketing Catalog" DefaultFontFamily="Arial, Helvetica, Geneva, Swiss, SunSans-Regular" PageLeftMargin="10" PageRightMargin="7" /><br>        </ExportSettings><br>        <ItemStyle ForeColor="#0066cc" /><br>    </telerik:RadGrid>
This always renders an empty page. whenever i remove the table, it works.
does anyone know how to achieve this?

thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 19 Sep 2013, 03:47 AM
Hi ,

There are a few rules that should be followed when exporting HTML tables to PDF:

* The table should define <colgroup> and <col> elements.
* The number of col elements should be equal to the number of the columns in the table body.
* Width in pixels (or another absolute units) should be set to the table.

<table width="300px">
  <colgroup>
    <col />
    <col />
  </colgroup>
  <tr>
    <td>
      Cell1
    </td>
    <td>
      Cell2
    </td>
  </tr>
</table>

Thanks,
Princy
Tags
Grid
Asked by
ck
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or