StandardTableView

The StandardTableView represents a table of data with columns and rows. Cells are organised in a model where each row is a model of [StandardListViewItem].

Properties

Same as ListView, and in addition:

  • current-sort-column (out int): Indicates the sorted column. -1 mean no column is sorted.
  • columns (in_out [TableColumn]): Defines the model of the table columns.
  • selection-mode (in SelectionMode): Defines the row selection mode.
  • rows ([[[ListViewItem]]]): Defines the model of table rows.
  • edit-item (in { row: int, column: int}): Defines the cell that is can be edited.
  • has-focus (out bool): True if the table view has focus.
  • current-row (in_out int): The index of the currently active row. -1 mean none is selected, which is the default.
  • drag-drop-enabled (in bool): If set to true drop event is enabled.

Callbacks

  • sort-ascending(/* column-index */ int): Emitted if the model should be sorted by the given column in ascending order.
  • sort-descending/* column-index */ (int): Emitted if the model should be sorted by the given column in descending order.
  • row-pointer-event((/* row-index */ int, /* event */ PointerEvent, /* absolute mouse position */ Point): Emitted on any mouse pointer event similar to TouchArea. Arguments are row index associated with the event, the PointerEvent itself and the mouse position within the tableview.
  • current-row-changed((/* current-row */ int): Emitted when the current row has changed because the user modified it.
  • key-pressed(/* event */ KeyEvent): Emitted when there is a key press event on the table view.
  • item-accepted(/* row */ int, /* column */ int, /* text */ string): Emitted when the text of the item is edited and after the enter is pressed.
  • drop-event(/* event */ DropEvent): Emitted when a row is dropped on an other row.

Functions

  • **set-current-row((/* current-row */ int): Sets the current row by index and brings it into view.

Example

import { StandardTableView } from "@coop/lib.slint";

export component Example inherits Window {
    width: 230px;
    height: 200px;

    StandardTableView {
        width: 230px;
        height: 200px;
        columns: [
            { title: "Header 1" },
            { title: "Header 2" },
        ];
        rows: [
            [
                { text: "Item 1" }, { text: "Item 2" },
            ],
            [
                { text: "Item 1" }, { text: "Item 2" },
            ],
            [
                { text: "Item 1" }, { text: "Item 2" },
            ]
        ];
    }
}