Documentation
¶
Index ¶
- type Column
- type Config
- type ID
- type Model
- func (m *Model[T]) AllIDs() []ID
- func (m *Model[T]) AppendRow(row T)
- func (m *Model[T]) DeleteRowByID(id ID)
- func (m *Model[T]) Fetch(setLoading bool) tea.Cmd
- func (m *Model[T]) GetAllRows() []T
- func (m *Model[T]) GetColumnByID(id ID) *Column
- func (m *Model[T]) GetFilteredRows() iter.Seq[T]
- func (m *Model[T]) GetHighlightedRows() iter.Seq[T]
- func (m *Model[T]) GetRowByID(id ID) T
- func (m *Model[T]) GetRows() iter.Seq[T]
- func (m *Model[T]) GetSelectedRow() (v T, found bool)
- func (m *Model[T]) GetVisibleRows() iter.Seq[T]
- func (m *Model[T]) GoToBottom()
- func (m *Model[T]) GoToTop()
- func (m *Model[T]) IDs() []ID
- func (m *Model[T]) Init() tea.Cmd
- func (m *Model[T]) MoveDown(n int)
- func (m *Model[T]) MoveLeft(n int)
- func (m *Model[T]) MoveRight(n int)
- func (m *Model[T]) MoveUp(n int)
- func (m *Model[T]) PrependRow(row T)
- func (m *Model[T]) SetColumns(columns []*Column)
- func (m *Model[T]) SetDimensions(width, height int)
- func (m *Model[T]) SetFilter(filter string)
- func (m *Model[T]) SetHeight(height int)
- func (m *Model[T]) SetLoading() tea.Cmd
- func (m *Model[T]) SetRows(values []T)
- func (m *Model[T]) SetSelected(id ID)
- func (m *Model[T]) SetStyles(s Styles)
- func (m *Model[T]) SetWidth(width int)
- func (m *Model[T]) ToggleColumn(id ID, enabled bool)
- func (m *Model[T]) TotalFilteredRows() int
- func (m *Model[T]) TotalRows() int
- func (m *Model[T]) Update(msg tea.Msg) tea.Cmd
- func (m *Model[T]) UpdateRow(row T)
- func (m *Model[T]) View() string
- type Row
- type StaticRow
- type Styles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model[T Row] struct { *types.ComponentModel // contains filtered or unexported fields }
func (*Model[T]) AppendRow ¶
func (m *Model[T]) AppendRow(row T)
AppendRow appends a row to the table.
func (*Model[T]) DeleteRowByID ¶
DeleteRowByID deletes a row by its ID, if it exists.
func (*Model[T]) GetColumnByID ¶
GetColumnByID returns a column by its ID, if it exists.
func (*Model[T]) GetFilteredRows ¶
GetFilteredRows returns an iterator of rows that are filtered.
func (*Model[T]) GetHighlightedRows ¶
GetHighlightedRows returns an iterator of rows that are highlighted.
func (*Model[T]) GetRowByID ¶
GetRowByID returns a row by its ID, if it exists.
func (*Model[T]) GetRows ¶
GetRows returns an iterator of rows. If filtering is enabled, it will return the filtered results.
func (*Model[T]) GetSelectedRow ¶
GetSelectedRow returns the currently selected row. If there is no selected row (e.g. no data), will return false.
func (*Model[T]) GetVisibleRows ¶
GetVisibleRows returns an iterator of rows that are visible in the current view.
func (*Model[T]) GoToBottom ¶
func (m *Model[T]) GoToBottom()
GoToBottom moves the selected row, and view, to the bottom of the table.
func (*Model[T]) GoToTop ¶
func (m *Model[T]) GoToTop()
GoToTop moves the selected row, and view, to the top of the table.
func (*Model[T]) IDs ¶
IDs returns the IDs of the data. If filtering is enabled, it will return the filtered IDs. See also Model.AllIDs.
func (*Model[T]) PrependRow ¶
func (m *Model[T]) PrependRow(row T)
PrependRow prepends a row to the table.
func (*Model[T]) SetColumns ¶
SetColumns updates the columns, does some basic validation (at least 1 enabled, correct min/max widths, etc), panics if invalid, and updates internal caches.
func (*Model[T]) SetDimensions ¶
SetDimensions sets the dimensions of the table. Prefer this over [SetWidth] and [SetHeight] as it will be more efficient.
func (*Model[T]) SetFilter ¶
SetFilter sets the filter string and updates the table. Setting to an empty string will clear all filtering.
func (*Model[T]) SetLoading ¶
SetLoading returns a tea.Cmd that sets the loading state to true. Will automatically be set back to false once data has been updated/fetched/etc using Model.SetRows.
func (*Model[T]) SetRows ¶
func (m *Model[T]) SetRows(values []T)
SetRows sets the data for the table.
func (*Model[T]) SetSelected ¶
SetSelected sets the selected row to the given ID, if it exists. If it doesn't, it will default to the first row.
func (*Model[T]) ToggleColumn ¶
ToggleColumn toggles a specific column on or off.
func (*Model[T]) TotalFilteredRows ¶
TotalFilteredRows returns the number of filtered rows. If filtering is not enabled, it will return the total number of rows ignoring filtering (e.g. Model.TotalRows).