Skip to main content

Table

Table Widget API

Example usage for creating a simple table:

Iris.Table({ 4, true })
do
    Iris.SetHeaderColumnIndex(1)

    -- for each row
    for i = 0, 10 do

        -- for each column
        for j = 1, 4 do
            if i == 0 then
                -- 
                Iris.Text({ `H: {j}` })
            else
                Iris.Text({ `R: {i}, C: {j}` })
            end

            -- move the next column (and row when necessary)
            Iris.NextColumn()
        end
    end

Properties

Table

WidgetHasChildren
Table.Table: Iris.Table

A layout widget which allows children to be displayed in configurable columns and rows. Highly configurable for many different options, with options for custom width columns as configured by the user, or automatically use the best size.

When Resizable is enabled, the vertical columns can be dragged horizontally to increase or decrease space. This is linked to the widths state, which controls the width of each column. This is also dependent on whether the FixedWidth argument is enabled. By default, the columns will scale with the width of the table overall, therefore taking up a percentage, and the widths will be in the range of 0 to 1 as a float. If FixedWidth is enabled, then the widths will be in pixels and have a value of > 2 as an integer.

ProportionalWidth determines whether each column has the same width, or individual. By default, each column will take up an equal proportion of the total table width. If true, then the columns will be allocated a width proportional to their total content size, meaning wider columns take up a greater share of the total available space. For a fixed width table, by default each column will take the max width of all the columns. When true, each column width will the minimum to fit the children within.

LimitTableWidth is used when FixedWidth is true. It will cut off the table horizontally after the last column.

INFO

Once the NumColumns is set, it is not possible to change it without some extra code. The best way to do this is by using Iris.PushConfig() and Iris.PopConfig() which will automatically redraw the widget when the columns change.

local numColumns = 4
Iris.PushConfig({ columns = numColumns })
Iris.Table({ numColumns, ...})
do
    ...
end
Iris.End()
Iris.PopConfig()

:::danger Error: nil Always ensure that the number of elements in the widths state is greater or equal to the new number of columns when changing the number of columns.

:::

hasChildren = true
hasState = false
Arguments = {
    NumColumns: number, -- number of columns in the table, cannot be changed
    Header: boolean? = false, -- display a header row for each column
    RowBackground: boolean? = false, -- alternating row background colours
    OuterBorders: boolean? = false, -- outer border on the entire table
    InnerBorders: boolean? = false, -- inner bordres on the entire table
    Resizable: boolean? = false, -- the columns can be resized by dragging or state
    FixedWidth: boolean? = false, -- columns takes up a fixed pixel width, rather than a proportion of the total available
    ProportionalWidth: boolean? = false, -- minimises the width of each column individually
    LimitTableWidth: boolean? = false, -- when a fixed width, cut of any unused space
}
Events = {
    hovered: () -> boolean
}
States = {
    widths: State<{ number }>? -- the widths of each column if Resizable
}

Functions

NextColumn

Table.NextColumn() → ()

In a table, moves to the next available cell. If the current cell is in the last column, then moves to the cell in the first column of the next row.

NextRow

Table.NextRow() → ()

In a table, moves to the cell in the first column of the next row.

SetColumnIndex

Table.SetColumnIndex(indexnumber) → ()

In a table, moves to the cell in the given column in the same previous row.

Will erorr if the given index is not in the range of 1 to NumColumns.

SetRowIndex

Table.SetRowIndex(indexnumber) → ()

In a table, moves to the cell in the given row with the same previous column.

NextHeaderColumn

Table.NextHeaderColumn() → ()

In a table, moves to the cell in the next column in the header row (row index 0). Will loop around from the last column to the first.

SetHeaderColumnIndex

Table.SetHeaderColumnIndex(indexnumber) → ()

In a table, moves to the cell in the given column in the header row (row index 0).

Will erorr if the given index is not in the range of 1 to NumColumns.

SetColumnWidth

Table.SetColumnWidth(
indexnumber,
widthnumber
) → ()

In a table, sets the width of the given column to the given value by changing the Table's widths state. When the FixedWidth argument is true, the width should be in pixels >2, otherwise as a float between 0 and 1.

Will erorr if the given index is not in the range of 1 to NumColumns.

Show raw api
{
    "functions": [
        {
            "name": "NextColumn",
            "desc": "In a table, moves to the next available cell. If the current cell is in the last column,\nthen moves to the cell in the first column of the next row.\n    ",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 1973,
                "path": "lib/API.lua"
            }
        },
        {
            "name": "NextRow",
            "desc": "In a table, moves to the cell in the first column of the next row.\n    ",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 1993,
                "path": "lib/API.lua"
            }
        },
        {
            "name": "SetColumnIndex",
            "desc": "In a table, moves to the cell in the given column in the same previous row.\n\nWill erorr if the given index is not in the range of 1 to NumColumns.\n    ",
            "params": [
                {
                    "name": "index",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 2010,
                "path": "lib/API.lua"
            }
        },
        {
            "name": "SetRowIndex",
            "desc": "In a table, moves to the cell in the given row with the same previous column.\n    ",
            "params": [
                {
                    "name": "index",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 2024,
                "path": "lib/API.lua"
            }
        },
        {
            "name": "NextHeaderColumn",
            "desc": "In a table, moves to the cell in the next column in the header row (row index 0). Will loop around\nfrom the last column to the first.\n    ",
            "params": [],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 2038,
                "path": "lib/API.lua"
            }
        },
        {
            "name": "SetHeaderColumnIndex",
            "desc": "In a table, moves to the cell in the given column in the header row (row index 0).\n\nWill erorr if the given index is not in the range of 1 to NumColumns.\n    ",
            "params": [
                {
                    "name": "index",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 2057,
                "path": "lib/API.lua"
            }
        },
        {
            "name": "SetColumnWidth",
            "desc": "In a table, sets the width of the given column to the given value by changing the\nTable's widths state. When the FixedWidth argument is true, the width should be in\npixels >2, otherwise as a float between 0 and 1.\n\nWill erorr if the given index is not in the range of 1 to NumColumns.\n    ",
            "params": [
                {
                    "name": "index",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "width",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 2078,
                "path": "lib/API.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "Table",
            "desc": "A layout widget which allows children to be displayed in configurable columns and rows. Highly configurable for many different\noptions, with options for custom width columns as configured by the user, or automatically use the best size.\n\nWhen Resizable is enabled, the vertical columns can be dragged horizontally to increase or decrease space. This is linked to\nthe widths state, which controls the width of each column. This is also dependent on whether the FixedWidth argument is enabled.\nBy default, the columns will scale with the width of the table overall, therefore taking up a percentage, and the widths will be\nin the range of 0 to 1 as a float. If FixedWidth is enabled, then the widths will be in pixels and have a value of > 2 as an\ninteger.\n\nProportionalWidth determines whether each column has the same width, or individual. By default, each column will take up an equal\nproportion of the total table width. If true, then the columns will be allocated a width proportional to their total content size,\nmeaning wider columns take up a greater share of the total available space. For a fixed width table, by default each column will\ntake the max width of all the columns. When true, each column width will the minimum to fit the children within.\n\nLimitTableWidth is used when FixedWidth is true. It will cut off the table horizontally after the last column.\n\n:::info\nOnce the NumColumns is set, it is not possible to change it without some extra code. The best way to do this is by using\n`Iris.PushConfig()` and `Iris.PopConfig()` which will automatically redraw the widget when the columns change.\n\n```lua\nlocal numColumns = 4\nIris.PushConfig({ columns = numColumns })\nIris.Table({ numColumns, ...})\ndo\n    ...\nend\nIris.End()\nIris.PopConfig()\n```\n\n:::danger Error: nil\nAlways ensure that the number of elements in the widths state is greater or equal to the\nnew number of columns when changing the number of columns.\n:::\n:::\n\n```lua\nhasChildren = true\nhasState = false\nArguments = {\n    NumColumns: number, -- number of columns in the table, cannot be changed\n    Header: boolean? = false, -- display a header row for each column\n    RowBackground: boolean? = false, -- alternating row background colours\n    OuterBorders: boolean? = false, -- outer border on the entire table\n    InnerBorders: boolean? = false, -- inner bordres on the entire table\n    Resizable: boolean? = false, -- the columns can be resized by dragging or state\n    FixedWidth: boolean? = false, -- columns takes up a fixed pixel width, rather than a proportion of the total available\n    ProportionalWidth: boolean? = false, -- minimises the width of each column individually\n    LimitTableWidth: boolean? = false, -- when a fixed width, cut of any unused space\n}\nEvents = {\n    hovered: () -> boolean\n}\nStates = {\n    widths: State<{ number }>? -- the widths of each column if Resizable\n}\n```\n    ",
            "lua_type": "Iris.Table",
            "tags": [
                "Widget",
                "HasChildren"
            ],
            "source": {
                "line": 1964,
                "path": "lib/API.lua"
            }
        }
    ],
    "types": [],
    "name": "Table",
    "desc": "Table Widget API\n\nExample usage for creating a simple table:\n```lua\nIris.Table({ 4, true })\ndo\n    Iris.SetHeaderColumnIndex(1)\n\n    -- for each row\n    for i = 0, 10 do\n\n        -- for each column\n        for j = 1, 4 do\n            if i == 0 then\n                -- \n                Iris.Text({ `H: {j}` })\n            else\n                Iris.Text({ `R: {i}, C: {j}` })\n            end\n\n            -- move the next column (and row when necessary)\n            Iris.NextColumn()\n        end\n    end\n```\n    ",
    "source": {
        "line": 1898,
        "path": "lib/API.lua"
    }
}