Module classes.vTable

A fully functional table widget, including vScrollbar and custom cells

Functions

set_data (data) set the dataprovider, while adding an internal id
assign_members (cell, defs, col_key, reserved_keys) assign additional properties to cells -
build () (re)build the actual view, using the current column/row count
cell_factory (ctype, cell_elm) produce a cell of the given type
remove_table () remove existing viewbuilder before rebuilding the table (using the maximum possible table size)
get_cell (row_idx, col_idx) retrieve direct reference to cell object
get_item_by_id (item_id)
get_content_width () get computed width of table, all (absolute) column widths put together
set_num_rows (num) set visible column count, rebuild if needed
get_col_type (idx)
get_col_key (idx) retrieve the key of a column definition
get_col_idx (key) retrieve the idx of a column definition by its key
get_col_width (idx, abs_only) retrieve the absolute width in pixels for a given column
compute_auto_width (idx) compute automatic width of column
get_col_margin (idx) retrieve the margin for a column
get_header_data (key)
get_header_ctype (key) retrieve a header type by key
set_header_def (key, member, value) specify a single header defitions by its key
set_column_def (key, member, value) specify a single column definition by its key
autosize_to_contents () call this whenever something has changed that will affect the computed height of the table - if resized (changed size), the external resize handler is invoked, giving the host application a chance to respond
set_width (val) GETTERS & SETTERS
get_height () get computed height of table, including header

Tables

self.header_cells (table>vCell) header cells (by key)
self.cells (table>row>col:vCell) table cells accessed like this: cells[row][col]

Fields

self.header_defs (table>table) header definition (by key) Required values: vTable.HEADER_DEF_KEYS + any cell members
self.column_defs (table>table>table) columns definition Required keys: vTable.COLUMN_DEF_KEYS
self.data (table>row>col:variant) the data an extra property, item_id, is added runtime
self.show_header (bool) show_header
self.scrollbar_width (int) TODO pass as separate constructor args
self.autosize (bool) automatically resize to fit number of rows
self.num_rows (int) number of visible rows
self.row_height (int) row height
self.header_height (int) header height
self.table_style (string) styles
self.row_offset (int) offset, vertical position in table use set_row_offset() to synchronize with scrollbar
self.on_update_complete (function) define this to perform post-update actions, such as custom row highlighting, tooltips etc.
self.on_resize (function) when table changed size (automatic resize)
self.map (table) internal version of data for quicker access
self.scrollbar (vScrollbar)
self.rebuild_requested (bool) when table dimensions have changed this will rebuild the table as part of the next update
self.uid (string) unique identifier for views
self._width (int) width


Functions

set_data (data)
set the dataprovider, while adding an internal id

Parameters:

  • data (table), indexed array
assign_members (cell, defs, col_key, reserved_keys)
assign additional properties to cells -

Parameters:

  • cell (vCell)
  • defs (table)
  • col_key (string or int)
  • reserved_keys (table) TODO skip reserved keys
build ()
(re)build the actual view, using the current column/row count
cell_factory (ctype, cell_elm)
produce a cell of the given type

Parameters:

  • ctype
  • cell_elm
remove_table ()
remove existing viewbuilder before rebuilding the table (using the maximum possible table size)
get_cell (row_idx, col_idx)
retrieve direct reference to cell object

Parameters:

  • row_idx
  • col_idx

Returns:

  1. vCell or nil
  2. table or nil (the matched item, if any)
get_item_by_id (item_id)

Parameters:

  • item_id (int)

Returns:

    table or nil (the matched item, if any)
get_content_width ()
get computed width of table, all (absolute) column widths put together

Returns:

    int
set_num_rows (num)
set visible column count, rebuild if needed

Parameters:

  • num (int)

Returns:

    vTable.CELLTYPE
get_col_type (idx)

Parameters:

  • idx (int)

Returns:

    vTable.CELLTYPE
get_col_key (idx)
retrieve the key of a column definition

Parameters:

  • idx (int)

Returns:

    string or nil
get_col_idx (key)
retrieve the idx of a column definition by its key

Parameters:

  • key (string)

Returns:

    int or nil
get_col_width (idx, abs_only)
retrieve the absolute width in pixels for a given column

Parameters:

  • idx (int)
  • abs_only (bool) only check for absolute values

Returns:

    int
compute_auto_width (idx)
compute automatic width of column

Parameters:

  • idx (int)

Returns:

    int
get_col_margin (idx)
retrieve the margin for a column

Parameters:

  • idx (int)

Returns:

  1. int
  2. variant or nil
get_header_data (key)

Parameters:

  • key (string)

Returns:

    variant or nil
get_header_ctype (key)
retrieve a header type by key

Parameters:

  • key (string)

Returns:

    vLib.vTable.CELLTYPE
set_header_def (key, member, value)
specify a single header defitions by its key

Parameters:

  • key (string), the column key
  • member (string), e.g.'notifier'
  • value (variant), e.g. a callback function or other type
set_column_def (key, member, value)
specify a single column definition by its key

Parameters:

  • key (string), the column key
  • member (string), e.g.'notifier'
  • value (variant), e.g. a callback function or other type
autosize_to_contents ()
call this whenever something has changed that will affect the computed height of the table - if resized (changed size), the external resize handler is invoked, giving the host application a chance to respond
set_width (val)
GETTERS & SETTERS

Parameters:

  • val TRACE("vTable set_width(val)",val)
get_height ()
get computed height of table, including header

Returns:

    int

Tables

self.header_cells
(table>vCell) header cells (by key)
self.cells
(table>row>col:vCell) table cells accessed like this: cells[row][col]

Fields

self.header_defs
(table>table) header definition (by key) Required values: vTable.HEADER_DEF_KEYS + any cell members
self.column_defs
(table>table>table) columns definition Required keys: vTable.COLUMN_DEF_KEYS
self.data
(table>row>col:variant) the data an extra property, item_id, is added runtime
self.show_header
(bool) show_header
self.scrollbar_width
(int) TODO pass as separate constructor args
self.autosize
(bool) automatically resize to fit number of rows
self.num_rows
(int) number of visible rows
self.row_height
(int) row height
self.header_height
(int) header height
self.table_style
(string) styles
self.row_offset
(int) offset, vertical position in table use set_row_offset() to synchronize with scrollbar
self.on_update_complete
(function) define this to perform post-update actions, such as custom row highlighting, tooltips etc.
  • elm (vTable)
self.on_resize
(function) when table changed size (automatic resize)
  • elm (vTable)
self.map
(table) internal version of data for quicker access
self.scrollbar
(vScrollbar)
self.rebuild_requested
(bool) when table dimensions have changed this will rebuild the table as part of the next update
self.uid
(string) unique identifier for views
self._width
(int) width
generated by LDoc 1.4.2