Export to PDF - Page Template not Working Correctly

2 posts, 0 answers
  1. Randy
    Randy avatar
    55 posts
    Member since:
    Jul 2009

    Posted 05 Apr Link to this post

    I have the following code in an MVC page. When I export to PDF, the content in the "page-template" script tag prints at the bottom of the grid on each page instead of the top, as I thought it should because I've specified a class type of "header".

     

    <script type="x/kendo-template" id="page-template">
        <div class="page-template">
            <div class="header">
                <div style="float: right">Page #: pageNum # of #: totalPages #</div>
                Multi-page grid with automatic page breaking
            </div>
        </div>
    </script>

    <div id="main-content" class="JeffreysContainer">
        <h3 class="text-center">Dealer Closeout History</h3>

        @(Html.Kendo().Grid<JeffreysOnline.Entities.vwCloseout>()
                .Name("grid")
                .Columns(columns =>
                {
                    columns.Bound(p => p.CloseoutDate).Width(120).Format("{0:MM/dd/yyyy}");
                    columns.Bound(p => p.BeginDate).Width(120).Format("{0:MM/dd/yyyy}");
                    columns.Bound(p => p.EndDate).Width(120).Format("{0:MM/dd/yyyy}");
                    columns.Bound(p => p.BoothNumber).Title("Booth").Width(80);
                    columns.Bound(p => p.DealerName).Title("Dealer Name").Width(100);
                    columns.Bound(p => p.DealerId).Title("Dealer Id").Width(100);
                    columns.Bound(p => p.RetailSales).Width(125);
                    columns.Bound(p => p.WholesaleSales).Width(125);
                    columns.Bound(p => p.LayawayPayments).Title("Deposit Payments").Width(125);
                    columns.Bound(p => p.RentWithheld).Title("Rent").Width(125);
                    columns.Bound(p => p.CommissionWithheld).Title("Commissions").Width(125);
                    columns.Bound(p => p.ChargeCardFees).Title("Charge Fees").Width(125);
                    columns.Bound(p => p.AssessmentWithheld).Title("Asessment").Width(125);
                    columns.Bound(p => p.TotalPayout).Title("Total Payout").Width(125);
                    columns.Bound(p => p.CheckNumber).Title("Check Number").Width(125);
                })
                .ToolBar(toolbar =>
                {
                    toolbar.Excel();
                    toolbar.Pdf();
                })
                .ColumnMenu()
                .Excel(excel => excel
                    .FileName("CloseoutHistory.xlsx")
                    .Filterable(true)
                    .AllPages(true)
                    .ProxyURL(Url.Action("ExcelExport", "Customer"))
                 )
                 .Pdf(pdf => pdf
                    .AllPages()
                    .AvoidLinks()
                    .PaperSize("A4")
                    .Scale(0.6)
                    .Margin("2cm", "1cm", "1cm", "1cm")
                    .Landscape()
                    .RepeatHeaders()
                    .Title("Closeout History")
                    .TemplateId("page-template")
                    .FileName("CloseoutHistory.pdf")
                    .ProxyURL(Url.Action("PdfExport", "Dealer"))
                )
                 .DataSource(dataSource => dataSource
                    .Ajax()
                    .Batch(false)                                               // We want to perform batch operations
                    .PageSize(50)                                               // Set the page size
                    .Events(events => events.Error("gridErrorHandler"))         // Define a function that gets called on an error
                    .Read(read => read.Action("ReadCloseoutHistory", "Closeout"))  // The Read method in the controller
                 )
        )
    </div>

  2. Stefan
    Admin
    Stefan avatar
    912 posts

    Posted 07 Apr Link to this post

    Hello Randy,

    This is not a known issue and I was not able to reproduce it in my testing scenario.

    I used the same template and configuration options as in the provided code, and the application is working as expected:

    http://dojo.telerik.com/EPUVif

    I can assume that the issue occurs due to a custom logic which we may be overlooking at this moment. Please provide a fully runnable example and I will gladly assist.

    Regards,
    Stefan
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top