Table
Table view.
Module | require("yue.gui") |
Type | Class |
Inherits | View |
The Table
does not store any data itself, to display data in Table
, users
have to provide a TableModel
.
How data are renderered depends on the type of column. It is also possible to create a custom renderer for arbitrary data.
Class methods
create()
Create a new Table
.
Return
Table
Methods
setmodel(model)
Set model
as table's data source.
Parameters
TableModel
model
getmodel()
Return table's model.
Return
TableModel
addcolumn(title)
Add a new column with title
, which shows readonly text.
Parameters
string
title
addcolumnwithoptions(title, options)
Add a new column with title
and options
.
Parameters
string
titleTable::ColumnOptions
options
getcolumncount()
Return the number of columns.
Return
integer
setcolumnsvisible(visible)
Set whether the columns header is visible.
On macOS adding column after hiding the header will result in missing columns in the header even after making the header visible again.
It is recommended to never show the header again after hiding the header, for consistent behaviors between platforms.
Parameters
boolean
visible
iscolumnsvisible()
Return whether the columns header is visible.
Return
boolean
setrowheight(height)
Set the height
of each row.
It is not recommended to change row height unless you are drawing all cells yourself, as the default text cells may not show decently under large or small height.
On Linux, due to platform implementations, this method has to be called before adding columns. It does not have any effect when columns have already been added.
Parameters
number
height
getrowheight()
Return the height
of each row.
Return
number
sethasborder(has)
Set whether the view has border.
Parameters
boolean
has
hasborder()
Return whether the view has border.
Return
boolean
enablemultipleselection(enable)
Set whether it is allowed to select more than one row at a time.
Parameters
boolean
enable
ismultipleselectionenabled()
Return whether it is allowed to select more than one row at a time.
Return
boolean
selectrow(row)
Select a row
.
Parameters
integer
row
getselectedrow()
Return the index of selected row.
For table that allows multiple selections, this will return the index of
first selected row. When no row is selected, -1
will be returned.
Return
integer
selectrows(rows)
Select multiple rows
.
Parameters
table
rows
getselectedrows()
Return selected rows' indexes.
Return
table
Events
onselectionchange(self)
Emitted when the table's selection has changed.
Parameters
Table
self
Preventable
No.onrowactivate(self, row)
Emitted when the user double-clicks a row.
Parameters
Table
selfinteger
row
Preventable
No.ontogglecheckbox(self, column, row)
Emitted when the user clicks a cell to toggle checkbox.
Parameters
Table
selfinteger
columninteger
row