---
title: StandardTableView
description: StandardTableView api
---

import SlintProperty from '@slint/common-files/src/components/SlintProperty.astro';
import CodeSnippetMD from '@slint/common-files/src/components/CodeSnippetMD.astro';
import Link from '@slint/common-files/src/components/Link.astro';

The `StandardTableView` represents a table of data with columns and rows. Cells
are organized in a model where each row is a model of
<SlintProperty typeName="struct" structName="StandardListViewItem" propName="model" default="[]" >
</SlintProperty>

<CodeSnippetMD imagePath="/src/assets/generated/std-widgets-standardtableview.png"  imageWidth="200" imageHeight="200"  imageAlt='std-widgets standardtableview example'>
```slint playground
import { StandardTableView } from "std-widgets.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" },
            ]
        ];
    }
}
```
</CodeSnippetMD>



## Properties

Same as <Link type="ListView" />, and in addition:

### current-sort-column
<SlintProperty typeName="int" propName="current-sort-column" default="-1" propertyVisibility="out">
Indicates the sorted column. -1 mean no column is sorted.
</SlintProperty>

### columns
<SlintProperty typeName="[struct]" structName="TableColumn" propName="columns" default="[]" propertyVisibility="in-out">
Defines the model of the table columns.

```slint 'columns: [{ title: "Header 1" }, { title: "Header 2" }];'
StandardTableView {
    columns: [{ title: "Header 1" }, { title: "Header 2" }];
    rows: [[{ text: "Item 1" }, { text: "Item 2" }]];
}
```
</SlintProperty>

### rows
<SlintProperty typeName="[[struct]]" structName="StandardListViewItem" propName="rows" default="[]" propertyVisibility="in-out">
Defines the model of table rows.

```slint 'rows: [{ text: "Item 1" }, { text: "Item 2" }];'
StandardTableView {
    columns: [{ title: "Header 1" }, { title: "Header 2" }];
    rows: [[{ text: "Item 1" }, { text: "Item 2" }]];
}
```
</SlintProperty>

### current-row
<SlintProperty typeName="int" propName="current-row" default="-1" propertyVisibility="in-out">
The index of the currently active row. -1 mean none is selected, which is the default.
</SlintProperty>

## Callbacks

### sort-ascending(int)
Emitted if the model should be sorted by the given column in ascending order.

### sort-descending(int)
Emitted if the model should be sorted by the given column in descending order.

### row-pointer-event(int, PointerEvent, 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(int)
Emitted when the current row has changed because the user modified it

```slint {5-7}
StandardTableView {
    columns: [{ title: "Header 1" }, { title: "Header 2" }];
    rows: [[{ text: "Item 1" }, { text: "Item 2" }]];

    current-row-changed(index) => {
        debug("Current row: ", index);
    }
}
```

## Functions

### set-current-row(int)
Sets the current row by index and brings it into view.
