jsPDF-AutoTable icon indicating copy to clipboard operation
jsPDF-AutoTable copied to clipboard

Multiple header rows using columns: ColumnDef[]

Open vny-cg opened this issue 4 years ago • 2 comments

Can we get the option to create multiple header rows using columns in the same way that you can use head with multiple CellDef[].

vny-cg avatar Apr 09 '21 15:04 vny-cg

Sounds look a great addition. Could you provide a screenshot or similar of the intended layout of your document?

simonbengtsson avatar Apr 10 '21 15:04 simonbengtsson

Sorry I can only show the headers row of the table but the image should be clear enough. I actually managed to figure out that this is possible to do via a combination of head and column into autodoc params object. This isn't to clear in the documentation and it would help other users figure it out. alternatively the ability to have multiple headers headers with the header object would be great.

head:

[
  [
    {
      content: "",
      colSpan: 1,
    },
    {
      content: "",
      colSpan: 1,
    },
    {
      content: "",
      colSpan: 1,
    },
    {
      content: "",
      colSpan: 1,
    },
    {
      content: "",
      colSpan: 1,
    },
    {
      content: "Price (LC)",
      colSpan: 1,
    },
    {
      content: "Returns ($)",
      colSpan: 3,
    },
    {
      content: "PCT",
      colSpan: 2,
    },
    {
      content: "MC",
      colSpan: 1,
    },
    {
      content: "Consensus PE",
      colSpan: 2,
    },
    {
      content: "",
      colSpan: 1,
    },
  ],
  [
    {
      content: "SEDOL",
    },
    {
      content: "Company",
    },
    {
      content: "Security Symbol",
    },
    {
      content: "Fund Name",
    },
    {
      content: "Analyst",
    },
    {
      content: "Today",
    },
    {
      content: "YTD",
    },
    {
      content: "-3Y",
    },
    {
      content: "-1Y",
    },
    {
      content: "RP",
    },
    {
      content: "FUND",
    },
    {
      content: "($bn)",
    },
    {
      content: "This Year",
    },
    {
      content: "Next Year",
    },
    {
      content: "Rating",
    },
  ],
]

columns:

[
  {
    dataKey: "sedol",
    header: "SEDOL",
  },
  {
    dataKey: "securityName",
    header: "Company",
  },
  {
    dataKey: "securitySymbol",
    header: "Security Symbol",
  },
  {
    dataKey: "fundName",
    header: "Fund Name",
  },
  {
    dataKey: "ownerUserName",
    header: "Analyst",
  },
  {
    dataKey: "priceTodayUsd",
    header: "Today",
  },
  {
    dataKey: "returnsUsdYtd",
    header: "YTD",
  },
  {
    dataKey: "returnsUsd3Ytd",
    header: "-3Y",
  },
  {
    dataKey: "returnsUsd1Ytd",
    header: "-1Y",
  },
  {
    dataKey: "rpPct",
    header: "RP",
  },
  {
    dataKey: "fundPct",
    header: "FUND",
  },
  {
    dataKey: "marketCapUsdBillions",
    header: "($bn)",
  },
  {
    dataKey: "consensusPeThisYear",
    header: "This Year",
  },
  {
    dataKey: "consensusPeNextYear",
    header: "Next Year",
  },
  {
    dataKey: "rating",
    header: "Rating",
  },
]

example headers: image

vny-cg avatar Apr 12 '21 08:04 vny-cg