Skip to main content
 首页 » 编程设计

c#之kendo 将数据提取到 pdf 文件在 asp.net mvc 中不起作用

2024年02月06日15lonelyxmas

我已经将kendo grid的提取选项实现到PDF文件,我在kendo论坛上找到了以下解决方案:

http://demos.telerik.com/aspnet-mvc/grid/pdf-export 

我按照说明安装了 pako.min.js 脚本并更新了我的剑道版本:我安装了 Q1 2015
即使当我从我的剑道网格中提取数据时,我得到的屏幕打印仅包含第一个剑道页面的数据,其中有我的剑道网格代码:

@(Html.Kendo().Grid<GesTim.WebApp.Areas.DataManagement.ViewModels.AgencyViewModels>().Name("Agencies").HtmlAttributes(new { style = "min-height:500px;" }) 
    .DataSource(dataSource => dataSource 
        .Ajax() 
        .Events(events => events.RequestEnd("onRequestEnd").Error("error")) 
        .Model(model => model.Id(c => c.Id)) 
        .Read(read => read.Action("Get", "xxxxx")) 
        .Destroy(destroy => destroy.Action("Delete", "xxxx")) 
        .ServerOperation(true) 
    ) 
 
    .Columns(columns => 
    { 
        columns.Bound(c => c.Id).Filterable(ftb => ftb.Cell(cell => cell.Operator(""))).Hidden(true).Visible(false); 
        columns.Bound(c => c.xxx).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").ShowOperators(false))); 
        columns.Bound(c => c.xxxx).Filterable(ftb => ftb.Cell(cell => cell.Operator("contains").ShowOperators(false))); 
 
        columns.Command(command => 
        { 
                command.Custom("Details").SendDataKeys(true).Click("showDetails").Text(" "); 
                command.Custom("Edit").SendDataKeys(true).Click("Editer").Text(" "); 
                command.Custom("Delete").Text(" ").Click("confirmRemove"); 
        }).Width("150px"); 
    }) 
 
            .Events(e => e.DataBound("onRowBound")) 
            .ToolBar(toolbar => 
      { 
              toolbar.Custom().Text("Ajouter xxx").Action("Create", "xxx", new { area = "DataManagement" }).HtmlAttributes(new { @class = "btn-ajouter" }); 
          toolbar.Excel().Text("Exporter au format Excel"); 
          **toolbar.Pdf();** 
      }) 
 
               .Excel(excel => excel 
                       .AllPages(true) 
                       .FileName("Liste des xxx.xlsx") 
                            .Filterable(true) 
                            .ProxyURL(Url.Action("Excel_Export_Save", "xxx")) 
                        ) 
        **.Pdf(pdf => pdf 
            .AllPages() 
                    .FileName("Liste des xxx.pdf") 
                    .ProxyURL(Url.Action("Pdf_Export_Save", "xxx")) 
                      )** 
 
                .Pageable(pageable => pageable 
                    .PageSizes(true) 
                .ButtonCount(10)) 
 
 
        .Groupable() 
        .Sortable() 
        .Filterable(ftb => ftb.Mode(GridFilterMode.Row)) 
 
) 

我的实现结果是,我得到了一个包含数据的文件,但在 kedno 网格中是这样的: 是不是漏了什么??请帮忙

请您参考如下方法:

我询问了剑道技术支持,他们告诉我,我的问题的解决方案是使用一种样式来提取 pdf 文件,如下所示:

 <style> 
        /* 
                Use the DejaVu Sans font for display and embedding in the PDF file. 
                The standard PDF fonts have no support for Unicode characters. 
            */ 
        .k-grid { 
            font-family: "DejaVu Sans", "Arial", sans-serif; 
        } 
 
        /* Hide the Grid header and pager during export */ 
        .k-pdf-export .k-grid-toolbar, 
        .k-pdf-export .k-pager-wrap, 
        .k-pdf-export a.k-button.k-button-icontext, 
        .k-pdf-export .k-filter-row, 
        .k-pdf-export .k-grouping-header, 
        .k-pdf-export .k-grid tr td:last-child { 
            display: none !important; 
        } 
 
    </style>