question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Altering cell text in createdCell hook breaks table style

See original GitHub issue

As you can see in the generated pdf, the text in the first column breaks in the middle of words. This happens, because the text of the cell in the last column gets altered in the createdCell hook. This is done to add the currency, because the service responds an integer value like 12000 and not text with the currency already attached. Seems to be a bug to me. Or maybe i did not understand how to “style” text. Is the createdCell hook the wrong place to do that?

I added a plunker as there seems to be a defect with the suggested codepen: https://plnkr.co/edit/SI1X4D2myWwzArH9JrPO?p=preview

off-topic: as you can see in the plunker, there is always the need to do

// prevent 'null' as text in table columns
if (!cell.raw) {
  cell.text = '';
}

in the createdCell hook because otherwise a null value would be rendered as text ‘null’. Maybe it would be a small cosmetic feature to automate this.

oh and also note the console output in the latest version. think there is a lost console.log somewhere in the code 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
simonbengtssoncommented, Jan 29, 2017

Added support for setting individual cell widths now. This is done by setting the style minCellWidth. It replaces the columnWidth style. This means that you would be able to set for example minCellWidth: 'wrap' for header cells while keep minCellWidth: 'auto' for body cells. This will be released in the upcoming version 3.

0reactions
erenustuncommented, Aug 8, 2019

To me it seems to be expected behavior since you are using overflow: linebreak; together with the default columnWidth: auto; on the name column? You can try setting the column style of the name column to wrap which will result in the following:

screen shot 2017-01-18 at 21 47 37

Thanks for the other comments btw! I fixed so that null is now printed as empty string and removed the extraneous log.

Hey,

How did you align the Preis th to the right?

I know it’s been 2 years, maybe something changed in codebase.

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

columns.createdCell - DataTables
This is a callback function that is executed whenever a cell is created (Ajax source, etc) or read from a DOM source. It...
Read more >
Changing text wrapping behavior in HTML table - css
I have an HTML table in which one particular cell can have long text (up to a paragraph). Is there a way to...
Read more >
AutoTable - Table plugin for jsPDF - npm
Generate pdf tables with javascript (jsPDF plugin). Latest version: 3.5.25, last published: 5 months ago. Start using jspdf-autotable in ...
Read more >
How to add a forced line break inside a table cell - TeX
As explained, it is by default vertically and horizontally centred. But you can change that either redefining \cellalign in the preamble, so it's...
Read more >
How to wrap table cell <td> content using CSS - GeeksforGeeks
For example, long words residing in the table cells can cause the cell width to ... The line breaks in the text can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found