mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 13:55:51 +03:00
[GH-ISSUE #768] Table pagination with fixed rows #561
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#561
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 @carpii on GitHub (Nov 13, 2022).
Original GitHub issue: https://github.com/rivo/tview/issues/768
Create a table with lots of rows, and a single fixed row....
Now page down twice, and page up twice
You would expect the table to be showing row 1 again. Instead what happens is that you select the fixed row, but the table body is still showing some rows from page 2.
As a workaround I change https://github.com/rivo/tview/blob/master/table.go#L1526
to
But it's probably not the correct solution (I only just started using tview today). Thanks for the great library!
@rivo commented on GitHub (Nov 14, 2022):
Colouring the fixed row blue with a black background kind of obscures the fact you're selecting that fixed row, too. It's selected initially and then again after hitting Page Down two times and Page Up two times. So the selection goes exactly where it's supposed to. (Make its text red to better see what's going on.)
Whether selecting a fixed row should also reset the scroll offset to 0 is debatable. I would say no. I can think of cases where you'd want to select a cell in a fixed row without at the same time having the entire table scroll back to the beginning.
In your specific case, unless you need the fixed row to be selectable, I would suggest making it unselectable:
Now your selection starts with the second row and paging down and up again will have the intended behaviour.
@carpii commented on GitHub (Nov 14, 2022):
I hadn't yet spotted the TableCell.SetSelected() api. Thats working much better, thanks
If I have a table of 1 unselectable fixed row, + 6 selectable rows, would you expect page up to always select the top selectable row?
This seems to work, unless the very last row is selected at which point it does nothing
@rivo commented on GitHub (Nov 15, 2022):
Depends on which row is currently selected and how tall your
Tableelement is. I would expect the select to move up by the number of visible rows.Can you post an example that illustrates this?
@carpii commented on GitHub (Nov 15, 2022):
Assuming term is big enough to view all rows...
If you select Row 2-4 and press Page Up, selection jumps to Row 1 as I'd expect.
If you select Row 5 and Page Up, table selection does not change
@rivo commented on GitHub (Nov 17, 2022):
Good catch! The latest commit should fix this.
Thanks for posting code to reproduce this.