TableView

A container which represents a two-dimensional grid of data, where each cell can contain different types of content and styles. It is often used to display large amounts of structured data, such as lists of items or records

Create from source

func NewTableView(session Session, params Params) TableView

Create new table view object and returns its interface

Create from resource

TableView {
    id = tableView,
    head-height = 1,
}

Interface description

Inherit methods, properties and events from ParentView, View

CellFrame(row, column int) Frame

Returns Frame of the specific cell

ReloadCell(row, column int)

Forces TableView to reload cell data and redraw

ReloadTableData()

Forces TableView to reload all data and redraw

Properties

"allow-selection"

Set the adapter which specifies whether cell/row selection is allowed. This property can be assigned by an implementation of TableAllowCellSelection or TableAllowRowSelection interface

Constant: AllowSelection

Types: TableAllowCellSelection, TableAllowRowSelection

Internal type is either TableAllowCellSelection, TableAllowRowSelection, see their description for more details

Examples

type rowDisablerData struct {
    disabledRows map[int]struct{}
}

func (data rowDisablerData) AllowRowSelection(row int) bool {
    if _, ok := data.disabledRows[row]; ok {
        return false
    }

    return true
}

type RowDisabler interface {
    rui.TableAllowRowSelection
}

func NewRowDisabler(disabledRows []int) RowDisabler {
    var ret rowDisablerData
    ret.disabledRows = make(map[int]struct{}, len(disabledRows))
    for _, disabledRow := range disabledRows {
        ret.disabledRows[disabledRow] = struct{}{}
    }

    return &ret
}
table := rui.NewTableView(session, rui.Params{
    rui.AllowSelection: NewRowDisabler([]int{0}),
    rui.SelectionMode:  rui.RowSelection,
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border"

Set a table cell's border. It sets the values of a border width, style, and color. Can also be used when setting parameters in properties "row-style", "column-style", "foot-style" and "head-style"

Constant: CellBorder

Types: BorderProperty, ViewBorder, ViewBorders

Internal type is BorderProperty, other types converted to it during assignment

See BorderProperty, ViewBorder and ViewBorders description for more details

Examples

TableView {
    cell-border = _{ style = solid, color = black, width = 1px,},
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorder: rui.ViewBorder{
        Style: rui.SolidLine,
        Color: rui.Black,
        Width: rui.Px(1),
    },
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-bottom"

Set a view's bottom border. It sets the values of a border width, style, and color

Constant: CellBorderBottom

Types: ViewBorder, BorderProperty, string

Internal type is BorderProperty, other types converted to it during assignment

See ViewBorder and BorderProperty description for more details

Examples

TableView {
    cell-border-bottom = _{ style = solid, color = black, width = 1px,},
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderBottom: rui.ViewBorder{
        Style: rui.SolidLine,
        Color: rui.Black,
        Width: rui.Px(1),
    },
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-bottom-color"

Set the line color of a table cell's bottom border

Constant: CellBorderBottomColor

Types: Color, string

Internal type is Color, other types converted to it during assignment

See Color description for more details

Examples

TableView {
    cell-border-bottom-color = black,
    cell-border-bottom-style = solid,
    cell-border-bottom-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderBottomColor: rui.Black,
    rui.CellBorderBottomStyle: rui.SolidLine,
    rui.CellBorderBottomWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-bottom-style"

Sets the line style of a table cell's bottom border. Default value is "none"

Constant: CellBorderBottomStyle

Types: int, string

Values

int string Description
0(NoneLine) "none" The border will not be drawn
1(SolidLine) "solid" Solid line as a border
2(DashedLine) "dashed" Dashed line as a border
3(DottedLine) "dotted" Dotted line as a border
4(DoubleLine) "double" Double line as a border

"cell-border-bottom-width"

Set the line width of a table cell's bottom border

Constant: CellBorderBottomWidth

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    cell-border-bottom-color = black,
    cell-border-bottom-style = solid,
    cell-border-bottom-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderBottomColor: rui.Black,
    rui.CellBorderBottomStyle: rui.SolidLine,
    rui.CellBorderBottomWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-color"

Set the line color for all four sides of a table cell's border

Constant: CellBorderColor

Types: Color, string

Internal type is Color, other types converted to it during assignment

See Color description for more details

Examples

TableView {
    cell-border-color = black,
    cell-border-style = solid,
    cell-border-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderColor: rui.Black,
    rui.CellBorderStyle: rui.SolidLine,
    rui.CellBorderWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-left"

Set a view's left border. It sets the values of a border width, style, and color. This property can be assigned a value of BorderProperty, ViewBorder types or BorderProperty text representation

Constant: CellBorderLeft

Types: ViewBorder, BorderProperty, string

Internal type is BorderProperty, other types converted to it during assignment

See ViewBorder and BorderProperty description for more details

Examples

TableView {
    cell-border-left = _{ style = solid, color = black, width = 1px,},
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderLeft: rui.ViewBorder{
        Style: rui.SolidLine,
        Color: rui.Black,
        Width: rui.Px(1),
    },
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-left-color"

Set the line color of a table cell's left border

Constant: CellBorderLeftColor

Types: Color, string

Internal type is Color, other types converted to it during assignment

See Color description for more details

Examples

TableView {
    cell-border-left-color = black,
    cell-border-left-style = solid,
    cell-border-left-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderLeftColor: rui.Black,
    rui.CellBorderLeftStyle: rui.SolidLine,
    rui.CellBorderLeftWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-left-style"

Set the line style of a table cell's left border. Default value is "none"

Constant: CellBorderLeftStyle

Types: int, string

Values

int string Description
0(NoneLine) "none" The border will not be drawn
1(SolidLine) "solid" Solid line as a border
2(DashedLine) "dashed" Dashed line as a border
3(DottedLine) "dotted" Dotted line as a border
4(DoubleLine) "double" Double line as a border

"cell-border-left-width"

Set the line width of a table cell's left border

Constant: CellBorderLeftWidth

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    cell-border-left-color = black,
    cell-border-left-style = solid,
    cell-border-left-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderLeftColor: rui.Black,
    rui.CellBorderLeftStyle: rui.SolidLine,
    rui.CellBorderLeftWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-right"

Set a view's right border. It sets the values of a border width, style, and color. This property can be assigned a value of BorderProperty, ViewBorder types or BorderProperty text representation

Constant: CellBorderRight

Types: ViewBorder, BorderProperty, string

Internal type is BorderProperty, other types converted to it during assignment

See ViewBorder and BorderProperty description for more details

Examples

TableView {
    cell-border-right = _{ style = solid, color = black, width = 1px,},
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderRight: rui.ViewBorder{
        Style: rui.SolidLine,
        Color: rui.Black,
        Width: rui.Px(1),
    },
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-right-color"

Set the line color of a table cell's right border

Constant: CellBorderRightColor

Types: Color, string

Internal type is Color, other types converted to it during assignment

See Color description for more details

Examples

TableView {
    cell-border-right-color = black,
    cell-border-right-style = solid,
    cell-border-right-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderRightColor: rui.Black,
    rui.CellBorderRightStyle: rui.SolidLine,
    rui.CellBorderRightWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-right-style"

Set the line style of a table cell's right border. Default value is "none"

Constant: CellBorderRightStyle

Types: int, string

Values

int string Description
0(NoneLine) "none" The border will not be drawn
1(SolidLine) "solid" Solid line as a border
2(DashedLine) "dashed" Dashed line as a border
3(DottedLine) "dotted" Dotted line as a border
4(DoubleLine) "double" Double line as a border

"cell-border-right-width"

Set the line width of a table cell's right border

Constant: CellBorderRightWidth

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    cell-border-right-color = black,
    cell-border-right-style = solid,
    cell-border-right-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderRightColor: rui.Black,
    rui.CellBorderRightStyle: rui.SolidLine,
    rui.CellBorderRightWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-style"

Set the line style for all four sides of a table cell's border. Default value is "none"

Constant: CellBorderStyle

Types: int, string

Values

int string Description
0(NoneLine) "none" The border will not be drawn
1(SolidLine) "solid" Solid line as a border
2(DashedLine) "dashed" Dashed line as a border
3(DottedLine) "dotted" Dotted line as a border
4(DoubleLine) "double" Double line as a border

"cell-border-top"

Set a view's top border. It sets the values of a border width, style, and color. This property can be assigned a value of BorderProperty, ViewBorder types or BorderProperty text representation

Constant: CellBorderTop

Types: ViewBorder, BorderProperty, string

Internal type is BorderProperty, other types converted to it during assignment

See ViewBorder and BorderProperty description for more details

Examples

TableView {
    cell-border-top = _{ style = solid, color = black, width = 1px,},
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderTop: rui.ViewBorder{
        Style: rui.SolidLine,
        Color: rui.Black,
        Width: rui.Px(1),
    },
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-top-color"

Set the line color of a table cell's top border

Constant: CellBorderTopColor

Types: Color, string

Internal type is Color, other types converted to it during assignment

See Color description for more details

Examples

TableView {
    cell-border-top-color = black,
    cell-border-top-style = solid,
    cell-border-top-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderTopColor: rui.Black,
    rui.CellBorderTopStyle: rui.SolidLine,
    rui.CellBorderTopWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-top-style"

Set the line style of a table cell's top border. Default value is "none"

Constant: CellBorderTopStyle

Types: int, string

Values

int string Description
0(NoneLine) "none" The border will not be drawn
1(SolidLine) "solid" Solid line as a border
2(DashedLine) "dashed" Dashed line as a border
3(DottedLine) "dotted" Dotted line as a border
4(DoubleLine) "double" Double line as a border

"cell-border-top-width"

Set the line width of a table cell's top border

Constant: CellBorderTopWidth

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    cell-border-top-color = black,
    cell-border-top-style = solid,
    cell-border-top-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderTopColor: rui.Black,
    rui.CellBorderTopStyle: rui.SolidLine,
    rui.CellBorderTopWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-border-width"

Set the line width for all four sides of a table cell's border

Constant: CellBorderWidth

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    cell-border-color = black,
    cell-border-style = solid,
    cell-border-width = 1px,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellBorderColor: rui.Black,
    rui.CellBorderStyle: rui.SolidLine,
    rui.CellBorderWidth: rui.Px(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-padding"

Sets the padding area on all four sides of a table cell at once. An element's padding area is the space between its content and its border

Constant: CellPadding

Types: BoundsProperty, Bounds, SizeUnit, float32, float64, int

Internal type is BoundsProperty, other types converted to it during assignment

See BoundsProperty, Bounds and SizeUnit description for more details

Examples

TableView {
    cell-padding = 1em,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellPadding: rui.Em(0.5),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})
table := rui.NewTableView(session, rui.Params{
    rui.CellPadding: rui.Bounds{
        Top:    rui.Em(0.5),
        Bottom: rui.Em(0.5),
        Left:   rui.Em(1),
        Right:  rui.Em(1),
    },
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-padding-bottom"

Set the height of the padding area to the bottom of a cell content

Constant: CellPaddingBottom

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    cell-padding-bottom = 0.5em,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellPaddingBottom: rui.Em(0.5),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-padding-left"

Set the width of the padding area to the left of a cell content. An element's padding area is the space between its content and its border

Constant: CellPaddingLeft

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    cell-padding-left = 1em,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellPaddingLeft: rui.Em(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-padding-right"

Set the width of the padding area to the left of a cell content. An element's padding area is the space between its content and its border

Constant: CellPaddingRight

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    cell-padding-right = 1em,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellPaddingRight: rui.Em(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-padding-top"

Set the height of the padding area to the top of a cell content. An element's padding area is the space between its content and its border

Constant: CellPaddingTop

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    cell-padding-top = 0.5em,
}
table := rui.NewTableView(session, rui.Params{
    rui.CellPaddingTop: rui.Em(0.5),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"cell-style"

Set the adapter which specifies styles of each table cell. This property can be assigned only by an implementation of TableCellStyle interface

Constant: CellStyle

Types: TableCellStyle

Examples

type cellDiagonalHighlightData struct {
    rui.Params
}

func (params cellDiagonalHighlightData) CellStyle(row, col int) rui.Params {
    if row == col {
        return params.Params
    }

    return rui.Params{}
}

func NewCellDiagonalHighlight(diagonalCellsParams rui.Params) rui.TableCellStyle {
    var ret cellDiagonalHighlightData
    ret.Params = diagonalCellsParams

    return &ret
}
table := rui.NewTableView(session, rui.Params{
    rui.CellStyle: NewCellDiagonalHighlight(rui.Params{
        rui.BackgroundColor: rui.Gray,
        rui.TextColor:       rui.White,
    }),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"column-span"

Sets the number of table column cells to be merged together. Used only when specifying cell parameters in the implementation of TableCellStyle

Constant: ColumnSpan

Types: int, string

Values

int string Description
0 "0" No merging will be applied
> 0 > "0" Number of columns including current one to be merged together

"column-style"

Set the adapter which specifies styles of each table column

Constant: ColumnStyle

Types: TableColumnStyle, []Params

Internal type is TableColumnStyle, other types converted to it during assignment

See TableColumnStyle description for more details

Examples

type columnEvenStyleData struct {
    rui.Params
}

func (params columnEvenStyleData) ColumnStyle(col int) rui.Params {
    if col%2 == 0 {
        return params.Params
    }

    return rui.Params{}
}

func NewColumnEvenStyle(style rui.Params) rui.TableColumnStyle {
    var ret columnEvenStyleData
    ret.Params = style

    return &ret
}
table := rui.NewTableView(session, rui.Params{
    rui.ColumnStyle: NewColumnEvenStyle(rui.Params{
        rui.BackgroundColor: rui.Gray,
        rui.TextColor:       rui.White,
    }),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"content"

Defines the content of the table

Constant: Content

Types: TableAdapter, [][]string, [][]any

Internal type is TableAdapter, other types converted to it during assignment

See TableAdapter description for more details

Examples

// Two dimensional array
table := rui.NewTableView(session, rui.Params{
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})
// Based on TableAdapter interface
type tableData struct {
    data [][]any
}

func (data tableData) Cell(row, col int) any {
    return data.data[row][col]
}

func (data tableData) ColumnCount() int {
    if len(data.data) == 0 {
        return 0
    }

    return len(data.data[0])
}

func (data tableData) RowCount() int {
    return len(data.data)
}

func NewTableData(data [][]any) rui.TableAdapter {
    var ret tableData
    ret.data = data

    return &ret
}
table := rui.NewTableView(session, rui.Params{
    rui.Content: NewTableData([][]any{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    }),
})

"current"

Sets the coordinates of the selected cell/row

Constant: Current

Types: CellIndex, int, string

Internal type is CellIndex, other types converted to it during assignment

See CellIndex description for more details

Conversion rules

int - specify index of current table row, current column index will be set to -1

string - can be one integer value which specify current row or pair of integer values separated by comma(,). When two values provided then first value specify current row index and second one specify column index

Examples

table := rui.NewTableView(session, rui.Params{
    rui.SelectionMode: rui.CellSelection,
    rui.Current: rui.CellIndex{
        Row:    1,
        Column: 1,
    },
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"foot-height"

Sets the number of rows in the table footer. The default value is 0 (no footer)

Constant: FootHeight

Types: int, string

Values

int string Description
0 "0" No footer
> 0 > "0" Number of rows act as a footer

"foot-style"

Set the footer style name or description of style properties

Constant: FootStyle

Types: string, Params

Internal type is either string or Params

Conversion rules

string - must contain style name defined in resources

Params - must contain style properties

Examples

Description of theme with style listed

theme {
    colors = _{
        footerBgColor = #FFBEBEBE,
        footerTextColor = #FFFFFFFF,
    },
    colors:dark = _{
        footerBgColor = #FFBEBEBE,
        footerTextColor = #FFFFFFFF,
    },
    styles [
        tableViewFooterStyle {
            background-color = @footerBgColor,
            text-color = @footerTextColor,
        },
    ]
}
table := rui.NewTableView(session, rui.Params{
    rui.FootStyle:  "tableViewFooterStyle",
    rui.FootHeight: 1,
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"gap"

Define the gap between rows and columns of a table

Constant: Gap

Types: SizeUnit, SizeFunc, string, float, int

Internal type is SizeUnit, other types converted to it during assignment

See SizeUnit description for more details

Examples

TableView {
    gap = 1em,
}
table := rui.NewTableView(session, rui.Params{
    rui.Gap: rui.Em(1),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"head-height"

Sets the number of rows in the table header. The default value is 0 (no header)

Constant: HeadHeight

Types: int, string

Values

int string Description
0 "0" No header
> 0 > "0" Number of rows act as a header

"head-style"

Set the header style name or description of style properties

Constant: HeadStyle

Types: string, Params

Internal type is either string or Params

Conversion rules

string - must contain style name defined in resources

Params - must contain style properties

Examples

Description of theme with style listed

theme {
    colors = _{
        headerBgColor = #FFBEBEBE,
        headerTextColor = #FFFFFFFF,
    },
    colors:dark = _{
        headerBgColor = #FFBEBEBE,
        headerTextColor = #FFFFFFFF,
    },
    styles [
        tableViewHeaderStyle {
            background-color = @headerBgColor,
            text-color = @headerTextColor,
        },
    ]
}
table := rui.NewTableView(session, rui.Params{
    rui.HeadStyle:  "tableViewHeaderStyle",
    rui.HeadHeight: 1,
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"row-span"

Set the number of table row to span. Used only when specifying cell parameters in the implementation of TableCellStyle

Constant: RowSpan

Types: int, string

Values

int string Description
0 "0" No merging will be applied
> 0 > "0" Number of rows including current one to be merged together

"row-style"

Set the adapter which specifies styles of each table row

Constant: RowStyle

Types: TableRowStyle, []Params

Internal type is TableRowStyle, other types converted to it during assignment

See TableRowStyle description for more details

Examples

type rowEvenStyleData struct {
    rui.Params
}

func (params rowEvenStyleData) RowStyle(row int) rui.Params {
    if row%2 == 0 {
        return params.Params
    }

    return rui.Params{}
}

func NewRowEvenStyle(style rui.Params) rui.TableRowStyle {
    var ret rowEvenStyleData
    ret.Params = style

    return &ret
}
table := rui.NewTableView(session, rui.Params{
    rui.RowStyle: NewRowEvenStyle(rui.Params{
        rui.BackgroundColor: rui.Gray,
        rui.TextColor:       rui.White,
    }),
    rui.Content: [][]string{
        {"Cell 1", "Cell 2"},
        {"Cell 3", "Cell 4"},
    },
})

"selection-mode"

Sets the mode of the table elements selection. Default value is "none"

Constant: SelectionMode

Types: int, string

Values

int string Description
0(NoneSelection) "none" Table elements are not selectable. The table cannot receive input focus
1(CellSelection) "cell" One table cell can be selected(highlighted). The cell is selected interactively using the mouse or keyboard(using the cursor keys)
2(RowSelection) "row" The entire table row can be selected (highlighted). The row is selected interactively using the mouse or keyboard (using the cursor keys)

"table-vertical-align"

Set the vertical alignment of the content inside a table cell

Constant: TableVerticalAlign

Types: int, string

Values

int string Description
0(TopAlign) "top" Top alignment
1(BottomAlign) "bottom" Bottom alignment
2(CenterAlign) "center" Center alignment
3(StretchAlign) "stretch" Work as baseline alignment, see below
4(BaselineAlign) "baseline" Baseline alignment

"text-align"

Sets the horizontal alignment of the content inside a table cell

Constant: TextAlign

Types: int, string

Values

int string Description
0(LeftAlign) "left" Left alignment
1(RightAlign) "right" Right alignment
2(CenterAlign) "center" Center alignment
3(JustifyAlign) "justify" Justify alignment

Events

"table-cell-clicked"

Occur when the user clicks on a table cell

Constant: TableCellClickedEvent

General listener format:

func(table rui.TableView, row, col int)

where: * table - Interface of a table view which generated this event * row - Row of the clicked cell * col - Column of the clicked cell

Allowed listener formats:

func(row, col int)

"table-cell-selected"

Occur when a table cell becomes selected

Constant: TableCellSelectedEvent

General listener format:

func(table rui.TableView, row, col int)

where: * table - Interface of a table view which generated this event * row - Row of the selected cell * col - Column of the selected cell

Allowed listener formats:

func(row, col int)

"table-row-clicked"

Occur when the user clicks on a table row

Constant: TableRowClickedEvent

General listener format:

func(table rui.TableView, row int)

where: * table - Interface of a table view which generated this event * row - Clicked row

Allowed listener formats:

func(row int)

"table-row-selected"

Occur when a table row becomes selected

Constant: TableRowSelectedEvent

General listener format:

func(table rui.TableView, row int)

where: * table - Interface of a table view which generated this event * row - Selected row

Allowed listener formats:

func(row int)

func NewSimpleTableAdapter(content [][]any) SimpleTableAdapter

Create new simple table adapter object and returns its interface

func NewTextTableAdapter(content [][]string) TextTableAdapter

Creates the new TextTableAdapter and returns its interface

func GetTableCellClickedListeners(view View, subviewID ...string) []func(TableView, int, int)

Returns listeners of event which occurs when the user clicks on a table cell. If there are no listeners then the empty list is returned. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableCellSelectedListeners(view View, subviewID ...string) []func(TableView, int, int)

Returns listeners of event which occurs when a table cell becomes selected. If there are no listeners then the empty list is returned. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableCellStyle(view View, subviewID ...string) TableCellStyle

Returns a TableCellStyle which defines styles of TableView cells. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableColumnStyle(view View, subviewID ...string) TableColumnStyle

Returns a TableColumnStyle which defines styles of TableView columns. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableContent(view View, subviewID ...string) TableAdapter

Returns a TableAdapter which defines the TableView content. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableCurrent(view View, subviewID ...string) CellIndex

Returns the row and column index of the TableView selected cell/row. If there is no selected cell/row or the selection mode is NoneSelection (0), then a value of the row and column index less than 0 is returned. If the selection mode is RowSelection (2) then the returned column index is less than 0. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableFootHeight(view View, subviewID ...string) int

Returns the number of rows in the table footer. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableHeadHeight(view View, subviewID ...string) int

Returns the number of rows in the table header. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableRowClickedListeners(view View, subviewID ...string) []func(TableView, int)

Returns listeners of event which occurs when the user clicks on a table row. If there are no listeners then the empty list is returned. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableRowSelectedListeners(view View, subviewID ...string) []func(TableView, int)

Returns listeners of event which occurs when a table row becomes selected. If there are no listeners then the empty list is returned. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableRowStyle(view View, subviewID ...string) TableRowStyle

Returns a TableRowStyle which defines styles of TableView rows. If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableSelectionMode(view View, subviewID ...string) int

Returns the mode of the TableView elements selection. Possible values are: NoneSelection (0), CellSelection (1) and RowSelection (2). If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func GetTableVerticalAlign(view View, subviewID ...string) int

Returns a vertical align in a TableView cell. Returns one of next values: TopAlign (0), BottomAlign (1), CenterAlign (2) and BaselineAlign (3). If the second argument (subviewID) is not specified or is an empty string then a value from the first argument (view) is returned

func ReloadTableViewCell(row, column int, view View, subviewID ...string) bool

Updates the given table cell. If the last argument (subviewID) is not specified or is an empty string then updates the cell of the first argument (TableView)

func ReloadTableViewData(view View, subviewID ...string) bool

Updates TableView. If the second argument (subviewID) is not specified or is an empty string then updates the first argument (TableView)

func TableViewByID(rootView View, id string) TableView

Return a TableView with id equal to the argument of the function or nil if there is no such View or View is not a TableView