Table
Table. It is copied into your app’s ui/ by qatjs add table: the code is yours to edit.
Example
| Order | Customer | Status | ||
|---|---|---|---|---|
| 10482 | Leyla Məmmədova | Delivered | 84.00 ₼ | |
| 10481 | Rəşad Əliyev | On the way | 212.50 ₼ | |
| 10480 | Aysel Quliyeva | New | 9.90 ₼ |
Selected: none
import Table from './ui/table/table.qx'
const orders = [
{ id: '10482', name: 'Leyla Məmmədova', status: 'Delivered', total: 84 },
{ id: '10481', name: 'Rəşad Əliyev', status: 'On the way', total: 212.5 },
{ id: '10480', name: 'Aysel Quliyeva', status: 'New', total: 9.9 },
]
export default function Example() {
let selected = state<string[]>([])
return (
<Table
label="Orders"
columns={[
{ key: 'id', label: 'Order', mono: true },
{ key: 'name', label: 'Customer' },
{ key: 'status', label: 'Status' },
{
key: 'total',
label: 'Total',
align: 'end',
mono: true,
sortable: true,
cell: (o) => o.total.toFixed(2) + ' ₼',
},
]}
rows={orders}
rowKey={(o) => o.id}
selectable
bind:selected={selected}
/>
<p>Selected: {selected.join(', ') || 'none'}</p>
)
}selected stateAdd it
npx qatjs add tableTable
As a custom element: <ui-table>.
| Prop | Type | Attribute |
|---|---|---|
label | string | yes |
columns | Column<T>[] | property only |
rows | T[] | property only |
rowKey | (row: T) => string | property only |
selectable | boolean | yes |
selected | string[] | property only |
sort | Sort | property only |
manualSort | boolean | yes |
density | 'comfortable' | 'compact' | yes |
height | number | yes |
actions | (row: T) => QatNode | property only |
actionsLabel | string | yes |
loading | boolean | yes |
empty | QatNode | property only |
error | QatNode | property only |
| Event | Detail |
|---|---|
on:update:selected | CustomEvent<string[]> |
on:update:sort | CustomEvent<Sort> |
Keys
| Key | Does |
|---|---|
| Space | select a row (selectable) |
| Enter | sort by a sortable header |