【问题标题】:Kendo Pdf export剑道PDF导出
【发布时间】:2018-08-17 20:45:16
【问题描述】:

我正在按分组列进行分页,我需要将分组列值添加到页眉。如何从页眉模板中访问分组的列值并进行渲染?

【问题讨论】:

  • 你能展示一下你是如何分页的吗?

标签: kendo-ui kendo-grid


【解决方案1】:

网格功能 pdf-export 仅在页眉和页脚模板的渲染时显示两个变量。可用的模板变量包括:

  • 页码
  • 总页数

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/pdf.template

变量在 kendo 编译模板中可用,这是一个匿名函数。该函数无权访问调用者,因此您在页眉/页脚渲染时对渲染进程的状态一无所知。 Kendo 可能会按顺序执行操作,或者可能会在网格完全呈现后稍后添加页眉/页脚——您只是不知道(除非您获得许可并想深入研究 PDFDocument 组件源代码)

This dojo 是一个使用pageNumtotalPages 的实验,还尝试通过虚拟列跟踪渲染过程。跟踪尝试没有成功。

{ field: "dummy", title: " ", width:1, template: "#computeDummy(data)#" }

    function computeDummy(data) {
      window.SupplierID = data.SupplierID;
      window.CategoryID = data.CategoryID;
      // console.log (data.SupplierID + " : " + data.CategoryID + " " + data.ProductName);
    }

并使用网格 pdf 页眉/页脚模板中的(全局)跟踪数据。

pdf: { …
            template: kendo.template($("#my-page-template").html()),
              margin: { top: "1.25cm", right: "1cm", bottom: "1cm", left: "1cm" },
} 

<script type="x/kendo-template" id="my-page-template">
    <div class="page-template">
        <div class="header">
            <div style="float: right">Page #:pageNum# of #:totalPages#</div>
            This is a header.  Last rendered: SupplierID=#=window.SupplierID# CategoryID=#=window.CategoryID# #console.log(data)#
        </div>
        <div class="footer">
            This is a footer.
            Page #:pageNum# of #:totalPages#
        </div>
    </div>
</script>

pdf 渲染和 html(浏览器)渲染的时间可能会受到内部承诺解决方案的影响,并且不要以可在 pdf 生成期间利用的方式排列。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 1970-01-01
    相关资源
    最近更新 更多