qat

Table

Table. It is copied into your app’s ui/ by qatjs add table: the code is yours to edit.

Example

Orders
OrderCustomerStatus
10482Leyla MəmmədovaDelivered84.00 ₼
10481Rəşad ƏliyevOn the way212.50 ₼
10480Aysel QuliyevaNew9.90 ₼

Selected: none

Example.qx34 lines, 1 reactive nameOpen in the playground
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 state

Add it

shell1 line
npx qatjs add table

Table

As a custom element: <ui-table>.

Table: props
PropTypeAttribute
labelstringyes
columnsColumn<T>[]property only
rowsT[]property only
rowKey(row: T) => stringproperty only
selectablebooleanyes
selectedstring[]property only
sortSortproperty only
manualSortbooleanyes
density'comfortable' | 'compact'yes
heightnumberyes
actions(row: T) => QatNodeproperty only
actionsLabelstringyes
loadingbooleanyes
emptyQatNodeproperty only
errorQatNodeproperty only
Table: events
EventDetail
on:update:selectedCustomEvent<string[]>
on:update:sortCustomEvent<Sort>

Keys

KeyDoes
Spaceselect a row (selectable)
Entersort by a sortable header