This is a migrated thread and some comments may be shown as answers.

PDF Export of hierarchical Grid

1 Answer 317 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 26 Oct 2017, 08:42 AM

Hello,

I have a hierarchical grid and I want to export it to pdf, but when I do this, only 2 pages are created, the rest is cut.

Can anybody tell me what I have to set, so that the complete grid is exported?

I also have another problem with the grid. The ProxyURL-Function does not work. The according method in code behind is never be executed and I don't know why. 

Here is the code:

<div class="col-sm-12" id="main">
            @(Html.Kendo().Grid<CMG_Configuration_Manager.Models.MachineInfo>()
        .Name("grid")
        .ToolBar(tools => tools.Pdf())
        .Pdf(pdf => pdf
            .AllPages()
            .AvoidLinks()
            .PaperSize("A4")
            .Scale(0.8)
            .Margin("2cm", "1cm", "1cm", "1cm")
            .Landscape()
            .TemplateId("page-template")
            .FileName("Kendo UI Grid Export.pdf")
            .ProxyURL(Url.Action("Pdf_Export_Save", "Home"))
             
        )
   
        .HtmlAttributes(new { style = "height: 800px; width:1000px" })
        .Scrollable(scrollable => scrollable.Height("auto"))
        .Groupable()
        .Sortable()
        .ClientDetailTemplateId("TemplateMaterial")
        .DataSource(dataSource => dataSource
            .Ajax()
            //.PageSize(10)
            .Read(read => read.Action("getSpGrid", "Home"))
        )
        .Events(events => events.DataBound("dataBound"))
            )
   
<script id="TemplateMaterial" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<CMG_Configuration_Manager.Models.MaterialInfo>()
            .Name("grid_#=msn_pkfk_serialnr_vchar#") // template expression, to be evaluated in the master context
            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("HistorianBinding_Material", "Home", new { SerialNr = "#=msn_pkfk_serialnr_vchar#" }))
            )
            .Events(events => events.DataBound("dataBound"))
            .Sortable()
            .ToClientTemplate()
             
            
    )
//And the Code in HomeController
 
[HttpPost]
        public ActionResult Pdf_Export_Save(string contentType, string base64, string fileName)
        {
            var fileContents = Convert.FromBase64String(base64);
 
            return File(fileContents, contentType, fileName);
        }

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 31 Oct 2017, 08:02 AM
Hello, Patrick,

Please have in mind that exporting a hierarchical Grid is one of the known limitations of the Grid PDF export:

https://docs.telerik.com/kendo-ui/controls/data-management/grid/pdf-export#known-limitations

As for the ProxyURL function, I can assume that the controller is not hit as the forceProxy property has to be set:

https://docs.telerik.com/kendo-ui/framework/save-files/introduction#set-server-proxy

Also, the following custom approach can be used as well:

https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/grid/pdf-export-server-side

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or