简体   繁体   English

在数据表 pdf 导出中添加序列号列

[英]add serial number column in datatable pdf export

i want to export my data table to PDF report.我想将我的数据表导出到 PDF 报告。

buttons: [
        {
          extend: "excel",
          footer: true,
          title: "my report",
          exportOptions: {
            columns: [1, 2, 3, 4],
          },
        },
        {
          extend: "pdf",
          footer: true,
          title: "my report",
          exportOptions: {
            columns: [1, 2, 3, 4],
          },
        },
      ]

the exported pdf is shown below.导出的 pdf 如下所示。

在此处输入图像描述

is there any method to add serial number at first column in my PDF report can any one help?有什么方法可以在我的 PDF 报告的第一列添加序列号,有人可以帮忙吗?

your can custom fields in datatable on export to pdf or excel through below code.您可以通过以下代码在数据表中自定义字段导出到 pdf 或 excel。

buttons: [
        {
          extend: "excel",
          footer: true,
          title: "my report",
          exportOptions: {
            columns: [1, 2, 3, 4],
          },
        },
        {
          extend: "pdf",
          footer: true,
          title: "my report",
          exportOptions: {
            columns: [1, 2, 3, 4],
          },
          customize: function (doc) {
            var col = doc.content[1].table.body;
            for (i = 1; i < col.length; i++) {
              col[i][0]["text"] = i;
            }
          },
        },
      ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM