Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent truncating on specific cell #27

Closed
jonathanasquier opened this issue Dec 13, 2017 · 4 comments
Closed

Prevent truncating on specific cell #27

jonathanasquier opened this issue Dec 13, 2017 · 4 comments

Comments

@jonathanasquier
Copy link

Hi, I'm using truncate: "..." and global parameter for my table and I'm trying to prevent truncation on a single cell. I Had no luck with truncate: false (default value) which sets the cell content to "false" (bug?)

Any idea?
Thanks!

@jonathanasquier
Copy link
Author

up?

@tecfu tecfu added the bug label Feb 28, 2018
@tecfu
Copy link
Owner

tecfu commented Feb 28, 2018

Thanks for catching that "truncate: false" bug. I'll check it out when I have a chance, or you can send me a pull request.

I haven't implemented truncation on a per cell basis, but again you could issue a pull request for it if you wanted.

@tecfu tecfu removed the bug label Feb 28, 2018
@tecfu
Copy link
Owner

tecfu commented Feb 28, 2018

I checked

truncate: false

And that works fine. Perhaps what you where doing was passing false as a string? Its meant to be a boolean when the value is false.

truncate: "false"

This would have indeed truncated lines with the word "false".


I've added support for truncation with no added character in 7c03d1b.

@tecfu tecfu closed this as completed Feb 28, 2018
@tecfu
Copy link
Owner

tecfu commented Mar 11, 2020

As of tty-table@4.1.0 you can set truncation on a cell-by-cell basis using the column formatter function. Here's an example:

formatter: function (cellValue, columnIndex, rowIndex) {
  if (rowIndex === 1) {
    this.configure({ truncate: false })
  }
  return cellValue
}

This example would turn off truncation and wrap the text in the second row of the column the formatter function is associated with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants