datatable

package module
v0.0.0-...-5954316 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 15 Imported by: 0

README

fyne-datatable

A data table widget for Fyne.

[!WARNING] This current status of this widget is: experimental. Use at your own risk.

Documentation

Overview

Package datatable provides a data-driven table widget for the Fyne GUI toolkit.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alignment

type Alignment uint

An Alignment represents the alignment the data in a colum.

const (
	AlignLeading  Alignment = iota // Left alignment
	AlignCenter                    // Center alignment
	AlignTrailing                  // Right alignment
)

type Column

type Column struct {
	// Alignment defines the alignment of the data in a column.
	Alignment Alignment

	// Title is the title displayed in the header of a column.
	Title string

	// Widths sets the width of a column.
	//
	// A column with width 0 will be auto-sized to fit the data in that column.
	// The minimum width is the width needed to fit a column's title.
	Width float32
}

A Column configures a column.

type Config

type Config struct {
	// Columns configures the columns of the table.
	Columns []Column // MANDATORY

	// Whether to hide the footer.
	FooterHidden bool

	// Whether to hide the header.
	HeaderHidden bool

	// Whether to hide the search bar.
	SearchBarHidden bool

	// Initially sorted column
	SortedColumnIndex int

	// Initial sort direction
	SortedColumnDirection SortDir
}

A Config configures a DataTable widget. All fields except for Columns are optional.

type DataTable

type DataTable struct {

	// Callback runs when an entry is selected.
	// index refers to the row in the original data.
	OnSelected func(index int)

	widget.BaseWidget
	// contains filtered or unexported fields
}

A DataTable is a Fyne widget implementing a data-driven table. It's public API is safe for concurrent use by multiple goroutines.

func New

func New(config Config) (*DataTable, error)

New returns a new DataTable widget. The widgets is configured with a Config struct. Returns an error if the validation of the config value failed.

func (*DataTable) CreateRenderer

func (w *DataTable) CreateRenderer() fyne.WidgetRenderer

func (*DataTable) SetData

func (w *DataTable) SetData(cells [][]string) error

SetData sets the content of all cells in the table. Returns an error if not all rows have the expected number of columns.

type SortDir

type SortDir uint

A SortDir represents the sort directions for a column

const (
	SortAsc  SortDir // Sort ascending
	SortDesc         // Sort descending
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL