Module vTable
(table>table) header definition (by key)
Required values: vTable.HEADER_DEF_KEYS
+ any cell members
set_data (data) |
|
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) |
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_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_item_by_id (item_id) |
DEPRICATED just here for compability |
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 and setters |
get_height () |
get computed height of table, including header |
Functions
-
set_data (data)
-
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)
-
produce a cell of the given type
Parameters:
-
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
TRACE("vTable
- col_idx
get_cell(row_idx,col_idx)",row_idx,col_idx)
Returns:
vCell or nil
-
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:
Returns:
vTable.CELLTYPE
-
get_col_type (idx)
-
Parameters:
Returns:
vTable.CELLTYPE
-
get_col_key (idx)
-
retrieve the key of a column definition
Parameters:
Returns:
string or nil
-
get_col_idx (key)
-
retrieve the idx of a column definition by its key
Parameters:
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:
Returns:
int
-
get_col_margin (idx)
-
retrieve the margin for a column
Parameters:
Returns:
int
-
get_item_by_id (item_id)
-
DEPRICATED just here for compability
Parameters:
- item_id
TRACE("vTable
get_item_by_id(item_id)")
Returns:
variant or nil
-
get_header_data (key)
-
Parameters:
Returns:
variant or nil
-
get_header_ctype (key)
-
retrieve a header type by key
Parameters:
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 and setters
Parameters:
-
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]
-
self.row_elms
-
(Viewbuilder.Rack) table rows
Fields
-
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.selection
-
vSelection
-
self.follow_row
-
(bool) when true, setting index can cause row_offset to follow
-
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.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