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" },
            ]
        ];
    }
}