Table with header row for Fyne UI library
fyne-headertable is a set of custom widgets for the Fyne toolkit that enhances Fyne's existing Table widget by adding headers for the columns.
A simple yet configurable header for data
A header that allows your users to sort the data in your table
To see the simple header in action, run
go run headertable/cmd/plainheader/main.go
This will create a table with static headers. This demo illustrates how changes to the underlying data store are reflected in the table by periodically changing values in the binding store.
The sorting header table is shown by running
go run headertable/cmd/sortheader/main.go
This illustrates sortable headers where selecting the sort icon sorts the underlying data.
Take a look at the samples for details, but the basic procedure is
- Create a
struct
that defines the data in the table - Create an array of the type and populate it with data
- Create an array of fyne Bindings using
binding.BindStruct
for each data element - Create a
headertable.TableOpts
instance to holdColAttrs
array that describes layout of the column header's text including:- Alignment
- Style
- Wrapping
- Width
RefWidth
string that is the basis for sizing the columnsBindings
the bindings created above
- Create a Header Table using
headertable.NewHeaderTable
- Add the Header Table to the layout
- Fix problem where header table and data table become horizontally out of sync
A special thanks to rohanthewiz (Rohan Allison) for providing a basis for these widgets in his rohanthewiz/rtable: RTable is a thin wrapper around fyne table repo!