flextable

package module
v0.0.0-...-39890a0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: BSD-2-Clause Imports: 9 Imported by: 0

README

Flextable

Fyne table with headers + adjustable column width and sorting.

Use example

package main

import (
	"fmt"
	"strconv"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"git.sr.ht/~uid/flextable"
)

func GetTableData() *flextable.TableData {
	data := flextable.NewTableData("MyTable")
	for i := 0; i < 5; i++ {
		header := "Header - " + strconv.Itoa(i)
		for j := 0; j < 100; j++ {
			data.AddStringCell(header, strconv.Itoa(j)+
				" some long text to illustrate how that looks")
		}
	}
	return data
}

func main() {
	app := app.New()
	window := app.NewWindow("Flextable Example")

	data := GetTableData()

	table := flextable.NewTable(data, func(c *flextable.TableCell) {
		fmt.Printf("I have been tapped. Cell value %s, Row: %d, Column name: %s\n",
			c.Text(), c.Id.Row, c.ColumnName())
	})

	window.SetContent(table)
	window.Resize(fyne.NewSize(1000, 600))

	window.ShowAndRun()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CellType

type CellType int

type DataCell

type DataCell struct {
	StringValue string
	Row         int
	// contains filtered or unexported fields
}
type Header struct {
	TableCell
	// contains filtered or unexported fields
}

func NewHeader

func NewHeader(columnName string, bgColor color.Color, table *Table) *Header

func (*Header) CreateRenderer

func (h *Header) CreateRenderer() fyne.WidgetRenderer

func (*Header) RefreshSortIcon

func (h *Header) RefreshSortIcon()

func (*Header) SetText

func (h *Header) SetText(columnName string)

func (*Header) Tapped

func (h *Header) Tapped(_ *fyne.PointEvent)

type Table

type Table struct {
	widget.BaseWidget

	SelectionColor color.Color
	CellBgColor    color.Color
	// contains filtered or unexported fields
}

func NewTable

func NewTable(data *TableData, onClick func(cell *TableCell)) *Table

func (*Table) CreateRenderer

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

func (*Table) Refresh

func (t *Table) Refresh()

func (*Table) SetData

func (t *Table) SetData(data *TableData)

type TableCell

type TableCell struct {
	widget.BaseWidget

	Id widget.TableCellID
	// contains filtered or unexported fields
}

func NewCell

func NewCell(table *Table) *TableCell

func (*TableCell) ColumnName

func (c *TableCell) ColumnName() string

func (*TableCell) CreateRenderer

func (c *TableCell) CreateRenderer() fyne.WidgetRenderer

func (*TableCell) IsEmpty

func (c *TableCell) IsEmpty() bool

func (*TableCell) SetText

func (c *TableCell) SetText(text string)

func (*TableCell) Tapped

func (c *TableCell) Tapped(_ *fyne.PointEvent)

func (*TableCell) Text

func (c *TableCell) Text() string

type TableData

type TableData struct {
	TableName string
	TableId   string

	Columns []string // Used to save the order of columns

	RowIds      []string
	RowCategory string
	// contains filtered or unexported fields
}

func NewTableData

func NewTableData(tableName string) *TableData

func (*TableData) AddColumnFromTable

func (td *TableData) AddColumnFromTable(newColumnName, oldColumnName string, otherTable *TableData) error

func (*TableData) AddStringCell

func (td *TableData) AddStringCell(column string, value string)

func (*TableData) AddStringRow

func (td *TableData) AddStringRow(columns []string, row []string)

func (*TableData) Clear

func (td *TableData) Clear()

Remove rows and columns

func (*TableData) ColumnCount

func (td *TableData) ColumnCount() int

func (*TableData) Get

func (td *TableData) Get(col, row int) string

func (*TableData) GetColumn

func (td *TableData) GetColumn(columnName string) []DataCell

func (*TableData) GetFromColumn

func (td *TableData) GetFromColumn(column string, row int) string

func (*TableData) GetRows

func (td *TableData) GetRows(column string) []DataCell

func (*TableData) InsertStringCell

func (td *TableData) InsertStringCell(column string, row int, value string)

func (*TableData) RenameColumn

func (td *TableData) RenameColumn(oldName, newName string)

func (*TableData) RowCount

func (td *TableData) RowCount() int

func (*TableData) SetIds

func (td *TableData) SetIds(ids []string) error

First ID in list must be the tableId, following 1 for each row

func (*TableData) Sort

func (td *TableData) Sort(column string, ascending bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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