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

Export to PDF with RADGrid Multicolumn

8 Answers 147 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Krunal Doshi
Top achievements
Rank 1
Krunal Doshi asked on 17 Nov 2010, 12:31 PM
Hi,

I have designed a multicolumn RADGrid which displays labels. However, when I export it to PDF, it displays only in single column.
Here is the code snippet for your reference--

<telerik:RadGrid ID="grdReport" runat="server" AllowSorting="True" GridLines="None"
                                AllowPaging="True" Font-Names="Arial" Font-Size="10pt" Skin="Outlook"
                                AllowFilteringByColumn="true" PageSize="30" ShowHeader="false" EnableViewState="true"
                                OnPreRender="grdReport_PreRender" OnNeedDataSource="grdReport_NeedDataSource"
                                OnItemCommand="grdReport_ItemCommand" OnItemCreated="grdReport_ItemCreated">
                            <ExportSettings IgnorePaging="True" OpenInNewWindow="True">
                                <Pdf PageWidth="210mm" PageHeight="297mm" Author="VoltTrack" Creator="VoltTrack"
                                    Producer="VoltTrack" PageLeftMargin="0.5in" PageRightMargin="0.5in" />
                            </ExportSettings>
                            <PagerStyle Position="Top"/>
                            <MasterTableView CommandItemDisplay="Top" EnableViewState="true" TableLayout="Fixed">
                                <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                                <CommandItemSettings ShowExportToPdfButton="True" ShowAddNewRecordButton="False" />
                                    <ItemTemplate>
                                        <%# (((GridItem)Container).ItemIndex != 0)? "</td></tr></table>" : "" %>
                                        <asp:Panel ID="ItemContainer" CssClass='<%# (((GridItem)Container).ItemType == GridItemType.Item)? "item" : "alternatingItem" %>'
                                            runat="server">
                                            <b><%# Eval("C_Name")%></b>
                                            <br />
                                            SSN:
                                            <b><%# Eval("SSN")%></b>
                                            W/E:
                                            <b><%# Eval("Weekend_Date")%></b>
                                            <br />
                                            Branch:
                                            <b><%# Eval("Branch")%></b>
                                            Job#:
                                            <b><%# Eval("Job_Number")%></b>
                                            <br />
                                            <b><%# Eval("Cust_Name")%></b>
                                        </asp:Panel>
                                    </ItemTemplate>
                            </MasterTableView>
                            <HeaderStyle HorizontalAlign="Center" />
                            <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
                                <Scrolling EnableVirtualScrollPaging="True" />
                            </ClientSettings>
                        </telerik:RadGrid>

protected void grdReport_PreRender(object sender, EventArgs e)
        {
            int itemCount = (sender as RadGrid).MasterTableView.GetItems(GridItemType.Item).Length + (sender as RadGrid).MasterTableView.GetItems(GridItemType.AlternatingItem).Length;
            foreach (GridItem item in (sender as RadGrid).Items)
            {
                if (item is GridDataItem && item.ItemIndex < itemCount - 1)
                {
                    ((item as GridDataItem)["C_Name"] as TableCell).Controls.Add(new LiteralControl("<table style='display:none;width: 730px'><colgroup><col /><col /><col /></colgroup><tr><td>"));
                }
            }
        }


Can you please help?

Regards,
Krunal

8 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 23 Nov 2010, 05:29 PM
Hello Krunal,

I ran your code on my end but unfortunately I'm unable reproduce the issue. Please examine the attached screenshot and let me know if I'm leaving something out.

Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Krunal Doshi
Top achievements
Rank 1
answered on 29 Nov 2010, 11:56 AM
Hi,

Please have atleast 10 to 15 records, so you can see there will be multicolumn report created when you browse. But if you export the same, then you will see those labels in only one column.

Regards,
Krunal
0
Daniel
Telerik team
answered on 01 Dec 2010, 02:54 PM
Hello Krunal,

I added 30 records but still I see only one column. Could you please modify the attached project to help me reproduce the issue? Thanks.

Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Krunal Doshi
Top achievements
Rank 1
answered on 01 Dec 2010, 03:18 PM

Hi Danial,

Please add the style in Default.aspx page and check it whether you are able to replicate the issue. Let me know how can I export the same format to PDF.

<style type="text/css">
        .item, .alternatingItem
        {
            float: left;
            padding: 10px;
            margin: 5px;
            width: 200px;
            height: 70px;
            border: 1px solid threedshadow;
            text-align: left;
        }
  
        .item
        {
            background: whitesmoke !important;    
        }
        .alternatingItem
        {
            background: window !important;    
        }
  
        .item:hover, .alternatingItem:hover
        {
            background: silver !important;    
        }
    </style>

Regards,
Krunal

0
Krunal Doshi
Top achievements
Rank 1
answered on 06 Dec 2010, 05:12 PM
Hi,

Any suggestions please!

Regards,
Krunal
0
Daniel
Telerik team
answered on 06 Dec 2010, 10:06 PM
Hello Krunal,

I'm afraid you cannot export such layout using our PDF export. Also, please keep in mind that only the inline styles will be exported.
PDF export

Regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Krunal Doshi
Top achievements
Rank 1
answered on 07 Dec 2010, 10:27 AM
Hi,

Is there any chances where I can create Multicolumn report with inline styles so that I can export it correctly to PDF?

Regards,
Krunal
0
Daniel
Telerik team
answered on 09 Dec 2010, 05:05 PM
Hello Krunal,

Unfortunately our PDF export is not suitable for this scenario.
Please excuse us for the inconvenience.

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Krunal Doshi
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Krunal Doshi
Top achievements
Rank 1
Share this question
or