Skip to main content
Version: v2.4.0 (Current)

🗓️ Table

The Table widget is a structured grid used to display organized data in rows and columns. It is the most efficient way to present logs, schedules, or multi-parameter sensor data where a simple Label would be too cluttered.


⚙️ Properties (Props)

The Table configuration is defined by the TableWidget interface. It manages a dynamic 2D array of strings and controls the visual scaling of the grid.

PropertyTypeDescription
RowsnumberThe total number of horizontal rows.
ColumnsnumberThe total number of vertical columns.
Col Widthnumber[]An array defining the width in pixels for each specific column.
Cell ValuestringThe text content of a specific cell at (row, col).

🛠 Grid Management

Tables in Artok are designed for high-density information display:

  • Fixed Headers: You can style the top row differently to act as a header that provides context for the data below.
  • Cell Wrapping: If a string is too long for a cell, the engine can truncate it or wrap it based on the Label properties inherited by the cell.
  • Alignment: Each column can have its own text alignment (e.g., Left-aligned for names, Right-aligned for numbers).

🎨 Visual Styling

In the Inspector Panel, you can define the "Skeleton" and the "Skin" of the table:

  • Grid Lines: Adjust the thickness and color of the horizontal and vertical separators.
  • Striped Rows: Enable "Zebra Striping" (alternating background colors) to make long lists easier for the eye to follow.
  • Selection: Define a highlight color for when a user clicks a specific cell or row.

⚡ Runtime API (Lua)

Tables are frequently updated via the Logic and Events system to show live system logs or fluctuating data.

-- Update a specific cell (Row 2, Column 1)
tbl_logs:set_cell_value(2, 1, "Warning: Low Voltage")

-- Clear the table content
tbl_logs:clear()

-- Dynamically add a new row of data
local new_row = {"10:45", "Temp Sensor", "24.5C"}
tbl_status:add_row(new_row)

-- Get the selected row index
local selected = tbl_menu:get_selected_row()

MEMORY MANAGEMENT

Tables can become memory-intensive if they contain hundreds of rows.


🚀 Next Steps

  • Chart — Use if you need to visualize the numerical data from your table as a trend line.
  • Logic and Events — Learn how to export table data to a CSV file or SD card.