Documentation ¶
Index ¶
- type IconProvider
- type Table
- func (widget *Table) AllowAdd() *Table
- func (widget *Table) AllowAll() *Table
- func (widget *Table) AllowDelete() *Table
- func (widget *Table) AllowEdit() *Table
- func (widget *Table) AllowNone() *Table
- func (widget *Table) Do(queryParams *url.URL, data map[string]any) error
- func (widget *Table) DoDelete(deleteIndex int) error
- func (widget *Table) DoEdit(data map[string]any, editIndex int) error
- func (widget *Table) Draw(params *url.URL, buffer io.Writer) error
- func (widget *Table) DrawAdd(buffer io.Writer) error
- func (widget *Table) DrawAddString() (string, error)
- func (widget *Table) DrawEdit(index int, buffer io.Writer) error
- func (widget *Table) DrawEditString(index int) (string, error)
- func (widget *Table) DrawView(buffer io.Writer) error
- func (widget *Table) DrawViewString() (string, error)
- func (widget *Table) UseLookupProvider(lookupProvider form.LookupProvider) *Table
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IconProvider ¶
type Table ¶
type Table struct { // Required Fields Schema *schema.Schema // Data schema for the data in this table Form *form.Element // Form (UI Schema) that defines the columns being displayed Object any // Object containing the table data Path string // Path to the data in the object TargetURL string // URL to send the form data to Icons IconProvider // IconProvider generates HTML for icons // Optional Fields LookupProvider form.LookupProvider // Optional dependency to provide lookup data for fields CanAdd bool // If TRUE, then users can add new rows to the table CanEdit bool // If TRUE, then users can edit existing rows in the table CanDelete bool // If TRUE, then users can delete existing rows in the table }
Table defines all of the properties of a table widget
Example ¶
// Data schema defines the layout of the data. s := schema.New(schema.Array{ MaxLength: 10, Items: schema.Object{ Properties: schema.ElementMap{ "name": schema.String{}, "age": schema.Integer{}, }, }, }) // UI schema defines which field are displayed, and in which order f := form.Element{ Type: "layout-vertical", Children: []form.Element{ {Type: "text", Label: "Name", Path: "name"}, {Type: "number", Label: "Age", Path: "age"}, }, } // Define some data to render data := []map[string]any{ {"name": "John Connor", "age": 20}, {"name": "Sarah Connor", "age": 45}, } // Create the new table and render it in HTML table := New(&s, &f, &data, "", testIconProvider{}, "http://localhost/update-form") fmt.Println(table.DrawViewString())
Output:
func New ¶
func New(schema *schema.Schema, form *form.Element, object any, path string, iconProvider IconProvider, targetURL string) Table
New returns a fully initialiized Table widget (with all required fields)
func (*Table) AllowAll ¶
AllowAll modifies the table to allow all write actions (Add, Edit, Delete).
func (*Table) AllowDelete ¶
AllowDelete modifies the table to allow deleting existing rows.
func (*Table) DrawAddString ¶
DrawAddString returns a string representation of the table with a row for adding a new record
func (*Table) DrawEditString ¶
DrawEditString returns a string representation of the table with a single editable row
func (*Table) DrawViewString ¶
DrawViewString returns a string representation of the table (VIEW ONLY)
func (*Table) UseLookupProvider ¶
func (widget *Table) UseLookupProvider(lookupProvider form.LookupProvider) *Table
UseLookupProvider modifies the table to use the given lookup provider.
Click to show internal directories.
Click to hide internal directories.