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

Guide on table with different sized columns #293

Open
madpipeline opened this issue Feb 24, 2021 · 2 comments
Open

Guide on table with different sized columns #293

madpipeline opened this issue Feb 24, 2021 · 2 comments

Comments

@madpipeline
Copy link

Hello,

I've been trying to figure out how to use the table ColumnWidths to set my tables to have the proper widths in each column for it's content, but to no avail. An example code, or some documentation would be very useful for newcomers to the project on how to properly use this feature would be extremely useful.

@dingyuchen
Copy link

Not sure if you still need help, I was also trying to figure out how to size columns properly in a table.
In looking at the source code, ColumnWidths is an array of integers specifying the width for each column. ColumnResizer seems to be a function that modifies the ColumnWidths directly during each call to Draw. Therefore usage is probably something like this:

table := NewTable()
table.ColumnResizer = func() {
    w := table.Inner.Dx()
    table.ColumnWidths = []int{w/2, w/2}
}

I think that if you do not need dynamic resizing, you can probably just set ColumnWidths directly.

Hope this helps.

@madpipeline
Copy link
Author

I know it seems obvious. I thought so too, but and example still would not hurt, in the documentation. This ticket will jut get buried at some point.

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