New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Export Basics



Is Category?NameSearch GoogleSearch WikipediaSearch YouTubeImage
12
Page size:
Politics    
   CNN Search in Google Google Search in Wikipedia Wikipedia Search in YouTube YouTube CNN image
   NBC Search in Google Google Search in Wikipedia Wikipedia Search in YouTube YouTube NBC image
   ABC Search in Google Google Search in Wikipedia Wikipedia Search in YouTube YouTube ABC image
Sports    
  • Demo Configurator
Export Options
DefaultContent


Document Options



A4


This online demo demonstrates the export to PDF feature of the RadTreeList.
The approach is very straightforward - to export the treelist content to PDF format, simply use the ExportToPdf() server-side method. You can configure the exporting settings for the treelist through the RadTreeList.ExportSettings section. Also, there is additional sub-category (Pdf) dedicated on various configuration settings for the exported .pdf document.

In this demo you could also see the new TreeList CommandItem for built in export buttons

  • DefaultCS.aspx
  • DefaultCS.aspx.cs
  • styles.css
<%@ Page Language="C#" CodeFile="~/TreeList/Examples/Export/BasicExport/DefaultCS.aspx.cs"Inherits="Telerik.Web.Examples.TreeList.Export.ExportOverview.DefaultCS"  %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="ConfiguratorPanel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadTreeList1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ConfiguratorPanel1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ConfiguratorPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
<div class="demo-container no-bg">

    <asp:Button Text="Export to PDF" ID="Button1" runat="server" OnClick="Button1_Click"></asp:Button>
    <br />
    <br />
    <telerik:RadTreeList RenderMode="Lightweight" runat="server" ID="RadTreeList1" DataSourceID="SqlDataSource1" CommandItemDisplay="Top"
        AllowPaging="true" PageSize="5" DataKeyNames="id" ParentDataKeyNames="parentId"
        AutoGenerateColumns="false" OnItemCreated="RadTreeList1_ItemCreated">
        <ExportSettings>
            <Pdf PageLeftMargin="20" PageRightMargin="20"></Pdf>
        </ExportSettings>
        <CommandItemSettings ShowExportToPdfButton="true" />
        <Columns>
            <telerik:TreeListTemplateColumn UniqueName="TemplateColumn" HeaderText="Is Category?">
                <ItemTemplate>
                    <asp:CheckBox ID="CheckBox1" runat="server" Enabled="false"></asp:CheckBox>
                </ItemTemplate>
                <HeaderStyle Width="40px" />
            </telerik:TreeListTemplateColumn>
            <telerik:TreeListBoundColumn DataField="Text" UniqueName="Text" HeaderText="Name">
                <ItemStyle Font-Size="Small" HorizontalAlign="Left" VerticalAlign="Middle" />
                <HeaderStyle Width="80px" />
            </telerik:TreeListBoundColumn>
            <telerik:TreeListTemplateColumn UniqueName="SearchGoogleColumn" HeaderText="Search Google">
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# String.Format("http://www.google.com/search?hl=en&amp;q={0}&amp;btnG=Google+Search", Eval("text") ) %>'>
                        <asp:Image ID="Image1" runat="server" AlternateText="Search in Google" ImageUrl="~/TreeList/Examples/Export/BasicExport/images/google.png"></asp:Image>
                    </asp:HyperLink>
                    <asp:HyperLink ID="HyperLink1" Text="Google" NavigateUrl='<%# String.Format("http://www.google.com/search?hl=en&amp;q={0}&amp;btnG=Google+Search", Eval("text") ) %>'
                        runat="server"></asp:HyperLink>
                </ItemTemplate>
            </telerik:TreeListTemplateColumn>
            <telerik:TreeListTemplateColumn UniqueName="SearchWikipediaColumn" HeaderText="Search Wikipedia">
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl='<%# String.Format("http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search={0}", Eval("text") ) %>'>
                        <asp:Image ID="Image2" runat="server" AlternateText="Search in Wikipedia" ImageUrl="~/TreeList/Examples/Export/BasicExport/images/wikipedia.png"></asp:Image>
                    </asp:HyperLink>
                    <asp:HyperLink ID="HyperLink3" Text="Wikipedia" NavigateUrl='<%# String.Format("http://en.wikipedia.org/w/index.php?title=Special%3ASearch&search={0}", Eval("text") ) %>'
                        runat="server"></asp:HyperLink>
                </ItemTemplate>
            </telerik:TreeListTemplateColumn>
            <telerik:TreeListTemplateColumn UniqueName="SearchYouTubeColumn" HeaderText="Search YouTube">
                <ItemTemplate>
                    <asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl='<%# String.Format("http://www.youtube.com/results?search_query={0}", Eval("text") ) %>'>
                        <asp:Image ID="Image3" runat="server" AlternateText="Search in YouTube" ImageUrl="~/TreeList/Examples/Export/BasicExport/images/youtube.png"></asp:Image>
                    </asp:HyperLink>
                    <asp:HyperLink ID="HyperLink5" Text="YouTube" NavigateUrl='<%# String.Format("http://www.youtube.com/results?search_query={0}", Eval("text") ) %>'
                        runat="server"></asp:HyperLink>
                </ItemTemplate>
            </telerik:TreeListTemplateColumn>
            <telerik:TreeListImageColumn HeaderText="Image" UniqueName="ImageColumn" DataType="System.String"
                ImageHeight="60px" ImageWidth="60px" DataImageUrlFields="Text" DataImageUrlFormatString="images/{0}.jpg"
                DataAlternateTextField="Text" DataAlternateTextFormatString="{0} image">
            </telerik:TreeListImageColumn>
        </Columns>
    </telerik:RadTreeList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TelerikConnectionString %>"
        SelectCommand="SELECT * FROM [Links]"></asp:SqlDataSource>
    </div>
    <qsf:ConfiguratorPanel runat="server" ID="ConfiguratorPanel1" Title="Demo Configurator">
        <Views>
            <qsf:View>
                <qsf:ConfiguratorColumn ID="ConfiguratorColumn1" runat="server" Size="Narrow">
                    <fieldset>
                        <legend>Export Options</legend>
                    </fieldset>
                    <label for="RadComboBox1">
                        Export mode:</label>
                    <qsf:DropDownList runat="server" Width="170px" ID="DropDownList1">
                    </qsf:DropDownList>
                    <br />
                    <br />
                    <span class="checkbox">
                        <asp:CheckBox ID="CheckBox1" Text="Ignore paging" Checked="true" runat="server"></asp:CheckBox></span>
                    <span class="checkbox">
                        <asp:CheckBox ID="CheckBox2" Checked="true" Text="Open in new window" runat="server"></asp:CheckBox></span>
                </qsf:ConfiguratorColumn>
                <qsf:ConfiguratorColumn ID="ConfiguratorColumn2" runat="server" Size="Medium">
                    <fieldset>
                        <legend>Document Options</legend>
                    </fieldset>
                    <span class="checkbox">
                        <asp:CheckBox ID="CheckBox3" Checked="true" Text="Rotate paper" runat="server"></asp:CheckBox>
                    </span>
                    <br />
                    <br />
                    <label for="DropDownList2">
                        Paper size:</label><br />
                    <qsf:DropDownList runat="server" Width="170px" ID="DropDownList2" AutoPostBack="true" Height="300px" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged">
                    </qsf:DropDownList>
                    <br />
                    <br />
                    <asp:Panel ID="Panel1" runat="server" Visible="false">
                        <qsf:NumericTextBox runat="server" ID="NumericTextBox1" Label="Height: (mm)" Width="90px" NumberFormat-DecimalDigits="0" Value="297"></qsf:NumericTextBox>
                        <qsf:NumericTextBox runat="server" ID="NumericTextBox2" Label="Height: (mm)" Width="90px" NumberFormat-DecimalDigits="0" Value="210"></qsf:NumericTextBox>
                        <br />
                        <asp:Label ID="Label1" runat="server" Text="" Style='color: red' EnableViewState="false"></asp:Label>
                    </asp:Panel>
                </qsf:ConfiguratorColumn>
            </qsf:View>
        </Views>
    </qsf:ConfiguratorPanel>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance