Skip to content
New issue

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

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

Already on GitHub? # to your account

How to apply text alignment to all header columns? #340

Closed
hellt opened this issue Nov 17, 2024 · 4 comments
Closed

How to apply text alignment to all header columns? #340

hellt opened this issue Nov 17, 2024 · 4 comments

Comments

@hellt
Copy link

hellt commented Nov 17, 2024

I love my table header row to have center-aligned text, like this

╭───┬──────┬──────────────┬──────────────────────────────┬───────────────┬─────────┬────────────────┬──────────────────────╮
│ # │ Name │ Container ID │             Image            │      Kind     │  State  │  IPv4 Address  │     IPv6 Address     │
├───┼──────┼──────────────┼──────────────────────────────┼───────────────┼─────────┼────────────────┼──────────────────────┤
│ 1 │ srl  │ 7faefde8ee2e │ ghcr.io/nokia/srlinux:latest │ nokia_srlinux │ running │ 172.20.20.2/24 │ 3fff:172:20:20::2/64 │
╰───┴──────┴──────────────┴──────────────────────────────┴───────────────┴─────────┴────────────────┴──────────────────────╯

The problem is, that it seems setting the text alignment of the header columns is only possible with

table.SetColumnConfigs()

which needs to know either the column names, or indexes. I compile the table dynamically, so I might now know the names of the rows ahead of time.

At the same time, it seems there is no table.AddColumnConfigs() that would not overwrite the slice of column configs. How could I dynamically add the column config iterating over the slice of table.Row?

@jedib0t
Copy link
Owner

jedib0t commented Nov 17, 2024

Is the list of columns dynamic or the number of columns fixed?

@jedib0t
Copy link
Owner

jedib0t commented Nov 17, 2024

Hey @hellt ... with the linked PR that has been merged, you should be able to set up the default alignment you want on the rows/headers/footers. Sample usage is in the description of the PR. Note that Column-configs will override these values.

Use the "main" branch code and let me know if this works, and I'll cut a tag for you.

@hellt
Copy link
Author

hellt commented Nov 18, 2024

thanks for a quick turnover, @jedib0t
this worked great! Looking forward for a tagged release 👍

image

@jedib0t
Copy link
Owner

jedib0t commented Nov 18, 2024

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

No branches or pull requests

2 participants