Fyne API "widget.Table"

widget.Table


import "fyne.io/fyne/v2/widget"

Usage

type Table

type Table struct {
	BaseWidget

	Length       func() (int, int)
	CreateCell   func() fyne.CanvasObject
	UpdateCell   func(id TableCellID, template fyne.CanvasObject)
	OnSelected   func(id TableCellID)
	OnUnselected func(id TableCellID)
}

Table widget is a grid of items that can be scrolled and a cell selected. It’s performance is provided by caching cell templates created with CreateCell and re-using them with UpdateCell. The size of the content rows/columns is returned by the Length callback.

Since: 1.4

func NewTable

func NewTable(length func() (int, int), create func() fyne.CanvasObject, update func(TableCellID, fyne.CanvasObject)) *Table

NewTable returns a new performant table widget defined by the passed functions. The first returns the data size in rows and columns, second parameter is a function that returns cell template objects that can be cached and the third is used to apply data at specified data location to the passed template CanvasObject.

Since: 1.4

func (*Table) CreateRenderer

func (t *Table) CreateRenderer() fyne.WidgetRenderer

CreateRenderer returns a new renderer for the table.

Implements: fyne.Widget

func (*Table) ScrollTo

func (t *Table) ScrollTo(id TableCellID)

ScrollTo will scroll to the given cell without changing the selection. Attempting to scroll beyond the limits of the table will scroll to the edge of the table instead.

Since: 2.1

func (*Table) ScrollToBottom

func (t *Table) ScrollToBottom()

ScrollToBottom scrolls to the last row in the table

Since: 2.1

func (*Table) ScrollToLeading

func (t *Table) ScrollToLeading()

ScrollToLeading scrolls horizontally to the leading edge of the table

Since: 2.1

func (*Table) ScrollToTop

func (t *Table) ScrollToTop()

ScrollToTop scrolls to the first row in the table

Since: 2.1

func (*Table) ScrollToTrailing

func (t *Table) ScrollToTrailing()

ScrollToTrailing scrolls horizontally to the trailing edge of the table

Since: 2.1

func (*Table) Select

func (t *Table) Select(id TableCellID)

Select will mark the specified cell as selected.

func (*Table) SetColumnWidth

func (t *Table) SetColumnWidth(id int, width float32)

SetColumnWidth supports changing the width of the specified column. Columns normally take the width of the template cell returned from the CreateCell callback. The width parameter uses the same units as a fyne.Size type and refers to the internal content width not including the divider size.

Since: 1.4.1

func (*Table) Unselect

func (t *Table) Unselect(id TableCellID)

Unselect will mark the cell provided by id as unselected.

func (*Table) UnselectAll

func (t *Table) UnselectAll()

UnselectAll will mark all cells as unselected.

Since: 2.1