Documentation
¶
Overview ¶
Package datatable renders a server-driven table (REQ-REG-10). Sort, filter and paging state live in typed GET routes; the component only renders one page and links the next one.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DataTableFixtures = gx.Fixtures[DataTableProps[FixtureRow]]{ "Three": { Columns: FixtureColumns, Rows: []FixtureRow{{Name: "Alpha", Total: 10}, {Name: "Beta", Total: 20}, {Name: "Gamma", Total: 30}}, Page: Page{Number: 1, Size: 10, Total: 3}, Href: FixtureHref, }, "Empty": { Columns: FixtureColumns, Page: Page{Number: 1, Size: 10, Total: 0}, Href: FixtureHref, }, }
View Source
var FixtureColumns = []Column[FixtureRow]{ {Key: "name", Label: "Name", Sort: "name", Cell: func(r FixtureRow) gx.Node { return gx.Text(r.Name) }}, {Key: "total", Label: "Total", Cell: func(r FixtureRow) gx.Node { return gx.Text(strconv.Itoa(r.Total)) }}, }
FixtureColumns are the columns of the data table fixtures. The name column is a sort link.
Functions ¶
Types ¶
type Column ¶
type Column[T any] struct { // Key identifies the column in the row data. Key string // Label is the visible header text. Label string // Cell renders one cell. Cell func(T) gx.Node // Sort is the query value of the column when the header is a sort // link. Empty makes the column unsortable. Sort string }
Column is one typed column of a data table.
type DataTableProps ¶
type DataTableProps[T any] struct { // Columns are the typed columns, in display order. Columns []Column[T] // Rows are the rows of the current page. Rows []T // Page is the paging state: the page number, the page size and the // total row count. Page Page // Sort is the Sort value of the column the rows are sorted by. Empty // means no sort. Sort string // Dir is the sort direction: "asc" or "desc". Dir string // Href builds the URL of a sort link and of a paging link. Href Href // Empty renders in place of the rows when the page holds none. Empty gx.Node }
DataTableProps holds one rendered table.
type FixtureRow ¶
FixtureRow is the row type of the data table fixtures.
Click to show internal directories.
Click to hide internal directories.