mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 13:55:51 +03:00
[GH-ISSUE #1093] Need help with grid and table #794
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#794
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @TLINDEN on GitHub (May 3, 2025).
Original GitHub issue: https://github.com/rivo/tview/issues/1093
I am trying to use this library which seems to be easy to use and understand. However, I'm having two problems and I didn't find anything in the documentation which could help.
This is the sample code I'm using. It creates a two column grid which contains a table on the left column.
One problem is, that I'd like the table to fill the whole column, something like
width: 100%in CSS. The other problem is that it seems to be impossible to add cell spacing. I didn't find a solution for both.I'd appreciate any help with thes issues!
Many thanks in advance,
Tom
@manuecg commented on GitHub (May 21, 2025):
Hi, have you tried this?
func (data *Data) GetCell(row, column int) *tview.TableCell { return tview.NewTableCell(data.Rows[row][column]).SetExpansion(1) }@TLINDEN commented on GitHub (May 28, 2025):
Sorry for the late reply. Yes,
SetExpansion(1)did the trick.But I've got another problem: I want the table to have a header. So my idea was to put the header captions as row[0] and set the first row as non-selectable. However, it seems to be impossible to do that. The only thing I came up with was this:
But it doesn't work, the first row is still selectable.
Edited to add:
I managed to fix this, I replaced
table.SetContent(data).SetFixed(0, 0)with:Now I have a non-selectable table header. However, now the table is not expanded anymore:
Here's the gist of the changed example