-
Notifications
You must be signed in to change notification settings - Fork 26
Text Table
Pawel edited this page Jun 24, 2018
·
4 revisions
StdUi:Table(parent, width, height, rowHeight, columns, data)
Description:
Text table is widget that transforms your data matrix into table (like excel).
Arguments:
-
parent
Frame - object that should be a parent -
width
number (Optional) - Width of the table -
height
number (Optional) - Height of the table -
rowHeight
number (Optional) - Height of the table -
columns
number - Height of the table -
data
number - Height of the table
Columns format:
local columns = {
{header = 'Name', dataIndex = 'name', width = 20, align = 'RIGHT'},
{header = 'Price', dataIndex = 'price', width = 60},
};
-
header
- string that should be displayed on the top of column -
dataIndex
- table accepts indexed data format, so this is the index inside each row -
width
- width of column -
align
(optional, Default:'LEFT'
) Align of text in this column
Data format:
local data = {
{name = 'Item one', price = 12.22},
{name = 'Item two', price = 11.11},
{name = 'Item three', price = 10.12},
}
Each object represents table row. Columns define which elements gets drawn by setting dataIndex
.
Methods:
-
SetColumns(columns)
- Sets the new columns definition and does not redraw it, format is explained above -
SetData(data)
- Sets new data to display and does not redraw it -
AddRow(row)
- Add new table row (it modifies provided data variable) and does not redraw it -
DrawHeaders()
- (Re)draws headers -
DrawData()
- (Re)draws data -
DrawTable()
- (Re)draws both headers and data
Named children:
-
tbl.rowHeight
- number - row height you set by creating widget -
tbl.columns
- table - columns you set by creating widget -
tbl.tableData
- table - data you set by creating widget -
tbl.headers
- array of Frame - Array of headerFrame
's -
tbl.rows
- matrix of FontString - Matrix of dataFontString
's.
To get to specific cell: tbl.rows[y][x]
where y
is the row index and x
is the column index.
Returns:
Demo:
local columns = {
{header = 'Name', dataIndex = 'name', width = 100, align = 'RIGHT'},
{header = 'Price', dataIndex = 'price', width = 100},
};
local data = {
{name = 'Item one', price = 12.22},
{name = 'Item two', price = 11.11},
{name = 'Item three', price = 10.12},
{name = 'Item three', price = 10.12},
{name = 'Item three', price = 10.12},
{name = 'Item three', price = 10.12},
}
local tbl = StdUi:Table(window, 200, 500, 20, columns, data);