> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/sdk-dv-ui/tables/table.md). Agents can also search and read this documentation through its [MCP server](https://docs.rierino.com/~gitbook/mcp).

# Table

Shows rows in a table with search, drop-down filters, sorting and pages.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} }],
  "layout": {
    "type": "RTable",
    "bind": {
      "query": "SELECT [month], city, region, orders, revenue FROM orders ORDER BY [month] DESC, revenue DESC"
    },
    "props": {
      "columns": [
        { "header": "Month" },
        { "header": "City" },
        { "header": "Region" },
        { "header": "Orders" },
        { "header": "Revenue" }
      ],
      "filters": ["region", "city"]
    }
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`orders` (30 rows)

```json
[
  { "month": "2026-07", "city": "Boston", "region": "North", "orders": 40, "revenue": 3200 },
  { "month": "2026-07", "city": "Chicago", "region": "North", "orders": 53, "revenue": 3777 },
  { "month": "2026-07", "city": "Austin", "region": "South", "orders": 41, "revenue": 4354 },
  { "month": "2026-07", "city": "Miami", "region": "South", "orders": 54, "revenue": 4931 },
  { "month": "2026-07", "city": "Denver", "region": "West", "orders": 42, "revenue": 5508 },
  { "month": "2026-08", "city": "Boston", "region": "North", "orders": 47, "revenue": 4291 },
  { "month": "2026-08", "city": "Chicago", "region": "North", "orders": 60, "revenue": 4868 },
  { "month": "2026-08", "city": "Austin", "region": "South", "orders": 48, "revenue": 5445 },
  { "month": "2026-08", "city": "Miami", "region": "South", "orders": 61, "revenue": 3622 },
  { "month": "2026-08", "city": "Denver", "region": "West", "orders": 49, "revenue": 4199 },
  { "month": "2026-09", "city": "Boston", "region": "North", "orders": 54, "revenue": 5382 },
  { "month": "2026-09", "city": "Chicago", "region": "North", "orders": 42, "revenue": 5959 },
  { "month": "2026-09", "city": "Austin", "region": "South", "orders": 55, "revenue": 4136 },
  { "month": "2026-09", "city": "Miami", "region": "South", "orders": 43, "revenue": 4713 },
  { "month": "2026-09", "city": "Denver", "region": "West", "orders": 56, "revenue": 5290 },
  { "month": "2026-10", "city": "Boston", "region": "North", "orders": 61, "revenue": 4073 },
  { "month": "2026-10", "city": "Chicago", "region": "North", "orders": 49, "revenue": 4650 },
  { "month": "2026-10", "city": "Austin", "region": "South", "orders": 62, "revenue": 5227 },
  { "month": "2026-10", "city": "Miami", "region": "South", "orders": 50, "revenue": 5804 },
  { "month": "2026-10", "city": "Denver", "region": "West", "orders": 63, "revenue": 3981 },
  { "month": "2026-11", "city": "Boston", "region": "North", "orders": 43, "revenue": 5164 },
  { "month": "2026-11", "city": "Chicago", "region": "North", "orders": 56, "revenue": 5741 },
  { "month": "2026-11", "city": "Austin", "region": "South", "orders": 44, "revenue": 6318 },
  { "month": "2026-11", "city": "Miami", "region": "South", "orders": 57, "revenue": 4495 },
  { "month": "2026-11", "city": "Denver", "region": "West", "orders": 45, "revenue": 5072 },
  { "month": "2026-12", "city": "Boston", "region": "North", "orders": 50, "revenue": 6255 },
  { "month": "2026-12", "city": "Chicago", "region": "North", "orders": 63, "revenue": 4432 },
  { "month": "2026-12", "city": "Austin", "region": "South", "orders": 51, "revenue": 5009 },
  { "month": "2026-12", "city": "Miami", "region": "South", "orders": 64, "revenue": 5586 },
  { "month": "2026-12", "city": "Denver", "region": "West", "orders": 52, "revenue": 6163 }
]
```

{% endtab %}
{% endtabs %}

## Usage

```json
{
  "type": "RTable",
  "bind": {
    "query": "SELECT [month], city, region, orders, revenue FROM orders ORDER BY [month] DESC, revenue DESC"
  },
  "props": {
    "columns": [
      { "header": "Month" },
      { "header": "City" },
      { "header": "Region" },
      { "header": "Orders" },
      { "header": "Revenue" }
    ],
    "filters": ["region", "city"]
  }
}
```

Each row of the data is a row of the table. The table has:

* a **search box** that keeps the rows where any column contains the text, ignoring case;
* a **drop-down filter** for each field in `filters`, listing the values found in that field;
* **sorting**: click a column header to sort by it, again to sort the other way, and a third time to go back to the query's order;
* **pages** of 10 rows, with a choice of 5, 10 or 20 rows per page. On a narrow screen (under 640px), the page buttons become **Previous** and **Next**.

The search, filters, sorting and page size start over when the dashboard is reloaded.

## Columns

The columns are the fields of the query, in the order the query returns them. `columns` gives their header texts, in the same order.

{% hint style="danger" %}
**columns is required**

Without `columns`, the table can't be drawn, and the item it's in shows an error in place of its contents.
{% endhint %}

## Examples

### Summary table

Values are shown exactly as the query returns them: numbers aren't formatted, and long decimals show in full. Group, round and label values in the query instead.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} }],
  "layout": {
    "type": "RTable",
    "bind": {
      "query": "SELECT city, SUM(orders) AS orders, '$' + SUM(revenue) AS revenue, ROUND(SUM(revenue) / SUM(orders), 2) AS average FROM orders GROUP BY city ORDER BY orders DESC"
    },
    "props": {
      "columns": [
        { "header": "City" },
        { "header": "Orders" },
        { "header": "Revenue" },
        { "header": "Average order" }
      ]
    }
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`orders` (30 rows)

```json
[
  { "month": "2026-07", "city": "Boston", "region": "North", "orders": 40, "revenue": 3200 },
  { "month": "2026-07", "city": "Chicago", "region": "North", "orders": 53, "revenue": 3777 },
  { "month": "2026-07", "city": "Austin", "region": "South", "orders": 41, "revenue": 4354 },
  { "month": "2026-07", "city": "Miami", "region": "South", "orders": 54, "revenue": 4931 },
  { "month": "2026-07", "city": "Denver", "region": "West", "orders": 42, "revenue": 5508 },
  { "month": "2026-08", "city": "Boston", "region": "North", "orders": 47, "revenue": 4291 },
  { "month": "2026-08", "city": "Chicago", "region": "North", "orders": 60, "revenue": 4868 },
  { "month": "2026-08", "city": "Austin", "region": "South", "orders": 48, "revenue": 5445 },
  { "month": "2026-08", "city": "Miami", "region": "South", "orders": 61, "revenue": 3622 },
  { "month": "2026-08", "city": "Denver", "region": "West", "orders": 49, "revenue": 4199 },
  { "month": "2026-09", "city": "Boston", "region": "North", "orders": 54, "revenue": 5382 },
  { "month": "2026-09", "city": "Chicago", "region": "North", "orders": 42, "revenue": 5959 },
  { "month": "2026-09", "city": "Austin", "region": "South", "orders": 55, "revenue": 4136 },
  { "month": "2026-09", "city": "Miami", "region": "South", "orders": 43, "revenue": 4713 },
  { "month": "2026-09", "city": "Denver", "region": "West", "orders": 56, "revenue": 5290 },
  { "month": "2026-10", "city": "Boston", "region": "North", "orders": 61, "revenue": 4073 },
  { "month": "2026-10", "city": "Chicago", "region": "North", "orders": 49, "revenue": 4650 },
  { "month": "2026-10", "city": "Austin", "region": "South", "orders": 62, "revenue": 5227 },
  { "month": "2026-10", "city": "Miami", "region": "South", "orders": 50, "revenue": 5804 },
  { "month": "2026-10", "city": "Denver", "region": "West", "orders": 63, "revenue": 3981 },
  { "month": "2026-11", "city": "Boston", "region": "North", "orders": 43, "revenue": 5164 },
  { "month": "2026-11", "city": "Chicago", "region": "North", "orders": 56, "revenue": 5741 },
  { "month": "2026-11", "city": "Austin", "region": "South", "orders": 44, "revenue": 6318 },
  { "month": "2026-11", "city": "Miami", "region": "South", "orders": 57, "revenue": 4495 },
  { "month": "2026-11", "city": "Denver", "region": "West", "orders": 45, "revenue": 5072 },
  { "month": "2026-12", "city": "Boston", "region": "North", "orders": 50, "revenue": 6255 },
  { "month": "2026-12", "city": "Chicago", "region": "North", "orders": 63, "revenue": 4432 },
  { "month": "2026-12", "city": "Austin", "region": "South", "orders": 51, "revenue": 5009 },
  { "month": "2026-12", "city": "Miami", "region": "South", "orders": 64, "revenue": 5586 },
  { "month": "2026-12", "city": "Denver", "region": "West", "orders": 52, "revenue": 6163 }
]
```

{% endtab %}
{% endtabs %}

```sql
SELECT city,
  SUM(orders) AS orders,
  '$' + SUM(revenue) AS revenue,
  ROUND(SUM(revenue) / SUM(orders), 2) AS average
FROM orders GROUP BY city ORDER BY orders DESC
```

A value turned into text, such as `'$' + SUM(revenue)`, still sorts as a number, as long as all the values in the column have the same prefix.

### On a card

A [Card](https://docs.rierino.com/sdk-dv-ui/layout/card.md) needs a height, and the table doesn't shrink to fit it. Give the table `h-full overflow-auto` so it scrolls inside the card:

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": { "title": "Orders by month", "classes": { "rootExtra": "relative h-96" } },
    "items": [
      {
        "type": "RTable",
        "bind": {
          "query": "SELECT [month], SUM(orders) AS orders, SUM(revenue) AS revenue FROM orders GROUP BY [month]"
        },
        "props": {
          "columns": [{ "header": "Month" }, { "header": "Orders" }, { "header": "Revenue" }],
          "classes": { "rootExtra": "h-full overflow-auto" }
        }
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`orders` (30 rows)

```json
[
  { "month": "2026-07", "city": "Boston", "region": "North", "orders": 40, "revenue": 3200 },
  { "month": "2026-07", "city": "Chicago", "region": "North", "orders": 53, "revenue": 3777 },
  { "month": "2026-07", "city": "Austin", "region": "South", "orders": 41, "revenue": 4354 },
  { "month": "2026-07", "city": "Miami", "region": "South", "orders": 54, "revenue": 4931 },
  { "month": "2026-07", "city": "Denver", "region": "West", "orders": 42, "revenue": 5508 },
  { "month": "2026-08", "city": "Boston", "region": "North", "orders": 47, "revenue": 4291 },
  { "month": "2026-08", "city": "Chicago", "region": "North", "orders": 60, "revenue": 4868 },
  { "month": "2026-08", "city": "Austin", "region": "South", "orders": 48, "revenue": 5445 },
  { "month": "2026-08", "city": "Miami", "region": "South", "orders": 61, "revenue": 3622 },
  { "month": "2026-08", "city": "Denver", "region": "West", "orders": 49, "revenue": 4199 },
  { "month": "2026-09", "city": "Boston", "region": "North", "orders": 54, "revenue": 5382 },
  { "month": "2026-09", "city": "Chicago", "region": "North", "orders": 42, "revenue": 5959 },
  { "month": "2026-09", "city": "Austin", "region": "South", "orders": 55, "revenue": 4136 },
  { "month": "2026-09", "city": "Miami", "region": "South", "orders": 43, "revenue": 4713 },
  { "month": "2026-09", "city": "Denver", "region": "West", "orders": 56, "revenue": 5290 },
  { "month": "2026-10", "city": "Boston", "region": "North", "orders": 61, "revenue": 4073 },
  { "month": "2026-10", "city": "Chicago", "region": "North", "orders": 49, "revenue": 4650 },
  { "month": "2026-10", "city": "Austin", "region": "South", "orders": 62, "revenue": 5227 },
  { "month": "2026-10", "city": "Miami", "region": "South", "orders": 50, "revenue": 5804 },
  { "month": "2026-10", "city": "Denver", "region": "West", "orders": 63, "revenue": 3981 },
  { "month": "2026-11", "city": "Boston", "region": "North", "orders": 43, "revenue": 5164 },
  { "month": "2026-11", "city": "Chicago", "region": "North", "orders": 56, "revenue": 5741 },
  { "month": "2026-11", "city": "Austin", "region": "South", "orders": 44, "revenue": 6318 },
  { "month": "2026-11", "city": "Miami", "region": "South", "orders": 57, "revenue": 4495 },
  { "month": "2026-11", "city": "Denver", "region": "West", "orders": 45, "revenue": 5072 },
  { "month": "2026-12", "city": "Boston", "region": "North", "orders": 50, "revenue": 6255 },
  { "month": "2026-12", "city": "Chicago", "region": "North", "orders": 63, "revenue": 4432 },
  { "month": "2026-12", "city": "Austin", "region": "South", "orders": 51, "revenue": 5009 },
  { "month": "2026-12", "city": "Miami", "region": "South", "orders": 64, "revenue": 5586 },
  { "month": "2026-12", "city": "Denver", "region": "West", "orders": 52, "revenue": 6163 }
]
```

{% endtab %}
{% endtabs %}

```json
{
  "type": "RCard",
  "props": { "title": "Orders by month", "classes": { "rootExtra": "relative h-96" } },
  "items": [
    {
      "type": "RTable",
      "bind": { "query": "SELECT [month], SUM(orders) AS orders, SUM(revenue) AS revenue FROM orders GROUP BY [month]" },
      "props": {
        "columns": [{ "header": "Month" }, { "header": "Orders" }, { "header": "Revenue" }],
        "classes": { "rootExtra": "h-full overflow-auto" }
      }
    }
  ]
}
```

## Filters

`filters` lists **field names** from the query (not header texts). Each one gets a drop-down above the table with **All** and every value found in that field, in the order they first appear in the data (sort the query to sort them). Filters and the search box work together: a row is shown when it matches all of them.

## Empty data

When the query returns no rows, the table shows the search box and the page controls with no headers or rows ("Page 1 of 0"). With no data at all (no `bind`), it shows the `sample` rows.

## Props

| Prop      | Type                   | Default | Description                                                                   |
| --------- | ---------------------- | ------- | ----------------------------------------------------------------------------- |
| `columns` | `{ header: string }[]` |         | **Required.** Header text of each column, in the order of the query's fields. |
| `filters` | `string[]`             |         | Fields that get a drop-down filter. Text fields only.                         |
| `sample`  | `object[]`             | `[]`    | Rows shown when there is no data, for designing.                              |
| `classes` | `object`               |         | Class names for the parts, see Classes below.                                 |

In the Rierino designer: **Columns** and **Filters** (both JSON) and **Classes**.

## Classes

| Part         | Built-in classes                                                                                                                             | Styles                                                |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------- |
| `root`       | none                                                                                                                                         | The table, with its search, filters and page controls |
| `button`     | `relative inline-flex items-center px-4 py-2 border border-gray text-regular-14 rounded-md text-gray bg-white hover:bg-warmGray-50`          | **Previous** and **Next**, on narrow screens          |
| `pageButton` | `relative inline-flex items-center px-2 py-2 border border-gray bg-white text-regular-14 text-gray hover:bg-warmGray-50 hover:border-indigo` | The first, previous, next and last page buttons       |

Set `classes.<part>` to replace the built-in classes, or `classes.<part>Extra` to add to them. The header, rows and cells can't be styled from the definition.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rierino.com/sdk-dv-ui/tables/table.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
