Table

A widget where users can view, edit, and interact with data presented in a grid-like format. It allows developers to populate the table with data, set headers for rows and columns, and enable users to edit cell contents. This widget offers functionalities to manage and manipulate tabular data, including sorting, selecting cells, adding or removing rows/columns dynamically. It’s a powerful tool for displaying structured data or creating spreadsheet-like interfaces.

local table = Table(rows, columns) -- optional parameters; specfies number of rows and columns

Important

Row and column indexing starts at 0

Properties

setOnCellEditFinished(callback)

Executed when user finishes editing a particular cell

setOnCellClicked(callback)

Executed when a cell was clicked

setOnCellDoubleClicked(callback)

Executed when a cell gets double clicked

setOnCellSelection(callback)

Executed when a cell is selected

Params:

self, row, column

addData(row, column, text)

Adds text to row and column

setImageData(image, text, row, column)

Sets an image and text on specified row and column

setColumnHeaders(columns: table)

Sets columns for the widget,ie, {'Name', 'Age', 'Location', ...}

setRowHeaders(headers: table)

Same as above property

getCurrentColumn()

Returns the current column

getCurrentRow()

Returns the current row

setMaxColumns(columns)

Sets the maximum columns for the widget

setMaxRows(rows)

Sets the maximum rows for the widget

setColumnHeaderToolTip(column: number)

Sets the tooltip for a particular header index

getColumnHeaderText(column: number)

Returns the column header text

getColumnsCount()

Returns total columns in the widget

getRowsCount()

Returns total rows in the widget

setGridVisible(visibility)

Sets grid-lines visibility for the widget

setRowLabelsVisible(visibility)

Sets the visibility for row labels; 1,2,3,4,5 on the left hand side

setCellChild(row, column, child)

Sets a widget on a particular row and column

setAutoColumnResize()

Sets columns to automatically adjust to content

setAutoRowResize()

Sets rows to automatically adjust to content

setColumnFitsContent(column)

Manually adjust a particular column

deleteRow(row)

Deletes a particular row

setCellsEditable(editable: bool)

Enables or disables cell editing

setAltRowColors(altcolors: bool)

Sets alternating colors

setColumnSorting(enable: bool)

Eanbles or disables column header sorting

clear()

Clears all content, including the headers

clearContent()

Clears only values in the cells, excluding the headers and row labels

findDataItem(text)

Searches for particular text in the widget

insertColumnAt(column)

Inserts a new column on a specified column index

insertRowAt(row)

Inserts a new row on a specified row index

removeColumnAt(column)

Removes a column at a particular column index

removeRowAt(row)

Removes a row at a particular row index

getItemAt(row, column)

Returns a TableItem at a particular row and column

getSelectedCells()

Returns all selected cells

getSelectedCell()

Returns selected cell

setSpan(row, column, rowSpan, columnSpan)

Merges cells toegther, allowing them to span multiple rows and columns within the table. Useful for creating cells that cover a large area within the table layout