-
Notifications
You must be signed in to change notification settings - Fork 87
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
Display column names longer than its content #448
Comments
It's actually supposed to work this way by default. use tabled::{settings::{object::Rows, themes::ColumnNames, Disable}, Table};
fn main() {
let data = vec![
("Id", "Age", "Description"),
("1", "10min", "Test"),
("2", "10min", "1"),
("3", "10min", "2"),
];
let mut table = Table::new(data);
table.with(Disable::row(Rows::first()));
table.with(ColumnNames::default());
println!("{table}");
}
|
Here is the code to reproduce. use tabled::{settings::{themes::ColumnNames}, Table, Tabled};
use tabled::settings::object::Rows;
use tabled::settings::{Border, Color, Style};
use tabled::settings::themes::Colorization;
#[derive(Tabled)]
#[tabled(rename_all = "PascalCase")]
pub struct TestRow {
#[tabled(rename = "ID")]
id: usize,
age: String,
description: String,
}
fn main() {
let data = vec![
TestRow {
id: 1,
age: "10min".to_string(),
description: "1".to_string(),
},
TestRow {
id: 2,
age: "20min".to_string(),
description: "2".to_string(),
},
];
let mut table = Table::new(data);
let primary = Color::default();
let secondary = Color::new("\u{1b}[48;2;38;38;38m", "\u{1b}[49m");
table.with(Style::empty())
.modify(Rows::first(), Border::new().top('─'))
.with(ColumnNames::default())
.with(Colorization::rows([primary, secondary]));
println!("{table}");
}
But eventually I noticed if I change the order, the problem has solved. // This works as I expected
table.with(Style::empty())
.modify(Rows::first(), Border::new().top('─'))
.with(Colorization::rows([primary, secondary]))
.with(ColumnNames::default());
|
I think maybe we shall put some comment in the documentation about such behavior trick. But was this solved? |
Hi,
Can you fix the issue where
ColumnNames
are truncated if they are longer than the contents of the cell?(The column name was 'description')
The text was updated successfully, but these errors were encountered: