New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
How to export RadListView to PDF
Environment
Product | RadListView for ASP.NET AJAX |
Description
You can find below how to export the RadListView data to a pdf file with the help of RadClientExportManager.
Solution
Here is an example:
ASPX
<telerik:RadScriptManager ID="QsfScriptManager" runat="server" />
<telerik:RadClientExportManager ID="RadClientExportManager1" runat="server">
<PdfSettings FileName="ListViewExport.pdf" />
</telerik:RadClientExportManager>
<telerik:RadButton runat="server" ID="RadButton1" Text="Export ListView to PDF" AutoPostBack="false" OnClientClicked="OnClientClicked" />
<script>
function OnClientClicked(sender, args) {
var listview = $find("<%= RadListView1.ClientID %>");
var clientExportManager = $find("<%= RadClientExportManager1.ClientID %>");
clientExportManager.exportPDF($telerik.$(listview.get_element())); //clientExportManager.exportToPng($telerik.$(listview.get_element())) will export the content to a png image
}
</script>
<telerik:RadListView ID="RadListView1" Width="97%" AllowPaging="True" runat="server"
AllowSorting="true" OnNeedDataSource="RadListView1_NeedDataSource" ItemPlaceholderID="ProductsHolder"
DataKeyNames="OrderID">
<LayoutTemplate>
<fieldset style="width: 700px;" id="RadListView1">
<legend>Products</legend>
<asp:Panel ID="ProductsHolder" runat="server" />
</fieldset>
</LayoutTemplate>
<ItemTemplate>
<div style="float: left;">
<table cellpadding="0" cellspacing="0" style="width: 230px;">
<tr>
<td style="width: 20%;">Name:
</td>
<td style="width: 80%; padding-left: 5px;">
<%# Eval("ShipName") %>
</td>
</tr>
</table>
</div>
</ItemTemplate>
</telerik:RadListView>