Type Function Library widget.* Revision Release 2024.3703 Keywords table view, list view, TableViewWidget, insertRow See also widget.newTableView() TableViewWidget
This method is used for inserting rows into a TableViewWidget.
object:insertRow( options )
This function requires a single argument, options
, which is a table that accepts the following parameters:
String. An optional identification to assign to the row. Default value is the row's index.
Number. The total height of the row in pixels.
Table. Table of two RGB+A color settings, one each for the default and over states.
rowColor = { default={ 1, 1, 1 }, over={ 1, 0.5, 0, 0.2 } }
Table. A table of RGB+A values that define the color of the separator line, assuming lines are set to visible.
lineColor = { 0.5, 0.5, 0.5 }
Boolean. If true
, the row will be rendered as a category row. Category rows "stick" to the top of the table view as the user scrolls, indicating that the rows underneath are part of that category.
Table. A table which can contain information pertaining to the specific row. This information can then be accessed (read) in the row rendering function via event.row.params
and in the row touch listener via event.target.params
.
-- Insert 40 rows for i = 1, 40 do local isCategory = false local rowHeight = 36 local rowColor = { default={ 1, 1, 1 }, over={ 1, 0.5, 0, 0.2 } } local lineColor = { 0.5, 0.5, 0.5 } -- Make some rows categories if ( i == 1 or i == 21 ) then isCategory = true rowHeight = 40 rowColor = { default={ 0.8, 0.8, 0.8, 0.8 } } lineColor = { 1, 0, 0 } end -- Insert a row into the tableView tableView:insertRow( { isCategory = isCategory, rowHeight = rowHeight, rowColor = rowColor, lineColor = lineColor, params = {} -- Include custom data in the row } ) end