【问题标题】:kendo extract data to pdf file doesn't work asp.net mvc剑道将数据提取到pdf文件不起作用asp.net mvc
【发布时间】:2015-04-13 09:14:45
【问题描述】:

我已经实现了剑道网格的提取选项到PDF文件,我在剑道论坛中找到了以下解决方案:

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

我已按照说明安装了 pako.min.js 脚本并更新了我的剑道版本:我安装了 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 文件但它是空的吗?
  • @gardarvalur,我得到一个非空的 pdf 文件:我的 pdf 文件是我提出问题的图像
  • 哦,我明白了。老实说,我认为 Telerik 的包装就是这样。
  • @gardarvalur 但是 Telerik 的演示显示了一个 ordianr pdf 文件,你没有发现我的代码有什么问题吗??
  • 我看到了你的困境。 demos.telerik.com/kendo-ui/grid/pdf-export 演示页面清楚地显示您仅导出内容。我最后尝试了这个,我得到了和你一样的结果(带有网格的标题和所有)。您的代码似乎没问题。

标签: c# asp.net-mvc kendo-grid kendo-asp.net-mvc data-extraction


【解决方案1】:

我问了剑道技术支持,他们告诉我,我的问题的解决方案是使用一种样式来提取 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>

【讨论】:

  • 您能发布完整的视图和控制器操作吗?我有一个类似的问题,我已经包含了这种风格,但没有运气。非常感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-11
  • 2018-04-29
相关资源
最近更新 更多