剑道PDF输出

时间:2018-08-17 20:45:17

标签: kendo-ui kendo-grid

我正在按分组列分页,我需要将分组列值添加到页面标题。如何从页面标题模板访问分组的列值并呈现它?

1 个答案:

答案 0 :(得分:0)

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

  • pageNum
  • 总页数

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生成过程中加以利用。

相关问题