Skip to content

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

Closed
@hellt

Description

@hellt

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions