A tabular UI element with typed rows. Row data is automatically persisted to storage on every change and restored on next run.

const grid = UI.AddDataGrid("items", [
{ key: "name", title: "Name", type: "text" },
{ key: "active", title: "Active", type: "checkbox" },
]);
grid.OnRowAction((rowIndex, colKey, rowData) => {
Console.Log("row " + rowIndex + " col " + colKey);
});
interface DataGridWrapper {
    Hide(): void;
    Show(): void;
    Destroy(): void;
    GetValue(): Record<string, unknown>[];
    SetValue(rows: Record<string, unknown>[]): void;
    OnRowAction(
        callback: (
            rowIndex: number,
            columnKey: string,
            rowData: Record<string, unknown>,
        ) => void,
    ): void;
}

Hierarchy (View Summary)

Methods

  • Hides the element without destroying it. Call Show() to make it visible again.

    Returns void

  • Makes a previously hidden element visible again.

    Returns void

  • Permanently removes the element from the UI panel.

    Returns void

  • Returns all current rows as an array of plain objects keyed by column key.

    Returns Record<string, unknown>[]

  • Replaces all rows with the provided array. Persists to storage immediately.

    Parameters

    • rows: Record<string, unknown>[]

    Returns void

  • Fires when the user interacts with a button-type column cell.

    Parameters

    • callback: (rowIndex: number, columnKey: string, rowData: Record<string, unknown>) => void

    Returns void