RadGrid and exporting just the NestedViewTemplate to a PDF

1 Answer 45 Views
Top achievements
Rank 2
SSirica asked on 28 Apr 2022, 03:30 PM
I have a RadGrid with like 40 columns, so the grid has a NestedViewTemplate that I use to display the selected row in sort of a form/table view.  That all works fine.  What I'm looking to do is to incorporate the ability for the user to export the NestedViewTemplate view to a PDF.  I guess in a way, it's a quick way to generate a single item report.  I've been thru all the articles with the hierarchical stuff, but that's not my scenario, so they were no help.  

1 Answer, 1 is accepted

Sort by
Attila Antal
Telerik team
answered on 03 May 2022, 12:24 PM | edited on 03 May 2022, 12:26 PM

Hi SSirica,

You can use the RadClientExportManager component and export only the elements that you specify.

Here is a full example:

<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView DataKeyNames="OrderID">
            <div class="export-me">
                <telerik:RadCard ID="RadCard1" runat="server" Width="200px">
                    <telerik:CardTitleComponent runat="server">
                        OrderID #<%#  Eval("OrderID") %>
                    <telerik:CardSubtitleComponent runat="server">
                        Ordered on <%#  Eval("OrderDate") %>
                    <telerik:CardBodyComponent runat="server">
                        <p><strong>ShipName:</strong> <%#  Eval("ShipName") %></p>
                        <p><strong>ShipName:</strong> <%#  Eval("ShipCountry") %></p>
                    <telerik:CardActionsContainerComponent runat="server" CardActionsAlignment="Stretched">
                        <span class="k-button k-flat k-primary exportToPdf">Export to PDF</span>

<telerik:RadClientExportManager runat="server" ID="RadClientExportManager1">


C# code for data binding

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    (sender as RadGrid).DataSource = Enumerable.Range(1, 10).Select(x => new
        OrderID = x,
        OrderDate = DateTime.Now.Date.AddDays(x),
        Freight = x * .1,
        ShipName = "Name " + x,
        ShipCountry = "Country " + x


RadGrid Figure


JavaScript to attach the click event handler to the action buttons and to call the ClientExportManager's Export method for a specific element

function pageLoadHandler() {

    $telerik.$('.RadGrid .rgMasterTable .export-me .k-button.exportToPdf').on('click', function (e) {

        var $elementToExport = $telerik.$(this).closest('.export-me');

        var exp = $find("<%= RadClientExportManager1.ClientID %>");

    // Sys.Application.remove_load(pageLoadHandler);  


Some cosmetics to make the Expanded container look better

.RadGrid .rgMasterTable .export-me {
    padding: 10px;


Export Results





I hope this will help achieve the desired scenario.


Attila Antal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Asked by
Top achievements
Rank 2
Answers by
Attila Antal
Telerik team
Share this question