Telerik : UI for ASP.NET MVC

Version : 2016.3.1118.545

Hi folks,

I’m facing some difficulty with the export PDF. I’m using the great kendo Grid to get the minimal data from server using the pager.

When I ask for excel export, multi requests are executed to get all the data from the server in order to produce the excel file (client ide) => Works pretty well

When I ask for PDF export, multi request are executed to get all the data from the server in order to produce the PDF file (client side) => got an issue, see below.

Actually, if I comment the PaperSize option or use the paperSize(“auto”) I got all the pages but the TemplateId is not used. If I used the option paperSize(“A4”) the templateId (Header, footer) are displayed but only the data from the current pager are include to the pdf file.

Thx in advance for your help,

Any idea about it.

Below a piece of my code.

 @(Html.Kendo().Grid<Connexity.MvcUI.Converters.ToJson.AlertConverter.AlertInfoUIDto>()
        .HtmlAttributes(new { @data_scroll = "auto" })
        .Name("AlertHistoricGrid")
        .Events(e => e.DataBound("alertLib.gridDataBound"))
        .ToolBar(tools => tools.Excel().Text(Resources.Generic_Export + " " + Resources.Generic_Excel))
            .Excel(excel => excel
            .FileName(Resources.AlertHistoric_List_Title + ".xlsx")
            .AllPages(true)
            .Filterable(true)
            .ProxyURL(Url.Action("Telerik_Export_Save", "Helper"))
        )
        .ToolBar(tools => tools.Pdf().Text(Resources.Generic_Export + " " + Resources.Generic_ToPDF))
            .Pdf(pdf => pdf
            .AvoidLinks()
            //.PaperSize("A4") // uncomment this line to got only the data from current pager into the pdf export file
            .Scale(0.8)
            .Margin("2cm", "1cm", "1cm", "1cm")
            .Landscape()
            .RepeatHeaders()
            .TemplateId("PDFTemplate")
            .FileName(Resources.AlertHistoric_List_Title + ".pdf")
            .AllPages()
            .ProxyURL(Url.Action("Pdf_Export", "Alert"))
        )
        .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(15)
        .Read(read => read.Action("AlertInfo_Read", "Alert").Data("alertLib.getAdditionalData").Type(HttpVerbs.Post)
        )
        )
        .Columns(columns =>
        {
        columns.Template(@<span></span>).Width(10).ClientTemplate("#=library.getKendoTemplate(data,'SelectionTemplate')#")
        .HeaderTemplate(
            @<span class="grid-selection">
                <input name="cbSelectionAll" class="select-all" id="CBAlertAll" type="checkbox" />
                <label class="kgrid-selection" for="CBAlertAll"></label>
            </span>)
        .HeaderHtmlAttributes(new { Class = "header-checkbox-column" })
        .Title("")
        .Visible(canCloseMultipleAlerts)
        .HtmlAttributes(new { Class = "checkbox-column" });
        columns.Bound(p => p.StateName).Width(62).ClientTemplate("#=library.getKendoTemplate(State,'StateTemplate')#").Title(Resources.Generic_State);
        columns.Bound(p => p.AlertStartDateTime).ClientTemplate("#=library.getKendoTemplate(data,'StartDateTimeTemplate')#").Title(Resources.AlertHistoric_AlertStart);
        columns.Bound(p => p.AlertTypeName).Title(Resources.Generic_AlertType);
        columns.Bound(p => p.DeviceName).Title(Resources.Generic_Name);
        columns.Bound(p => p.DeviceIdentifiant).Title(Resources.Generic_Identifiant);
        columns.Bound(p => p.SensorNames).ClientTemplate("#=library.getKendoTemplate(Sensors,'SensorTemplate')#").Title(Resources.Generic_Sensor);
        columns.Bound(p => p.AlertEndDateTime).ClientTemplate("#=library.getKendoTemplate(data,'EndDateTimeTemplate')#").Title(Resources.AlertHistoric_AlertResolution);
        columns.Template(@<span></span>).ClientTemplate("#=library.getKendoTemplate(data,'ActionTemplate')#").Title(Resources.AlertHistoric_Actions);
        columns.Template(@<span>@item.SMSCount @item.EmailCount</span>).ClientTemplate("#=library.getKendoTemplate(data,'NotificationTemplate')#")
        .Title(Resources.AlertDetailsModal_AlertHistoricNotifications).Width(220);
        columns.Template(@<span></span>).Title("").Width(42).ClientTemplate(Html.ActionLink(" ", "DetailsModal", "Alert", new { idAlert = "#=IdAlert#" }, new { data_toggle = "modal", data_target = "\\#basicModal", data_modal = "", Class = "button detail" }).ToHtmlString())
            .HeaderHtmlAttributes(new { Class = "header-button-column" }).HtmlAttributes(new { Class = "button-column" });
        })
        .Sortable()
        .Pageable()
    )

Related posts

Recent Viewed