UI LibraryUI Library
Guide
Components
Styling
Repo
Guide
Components
Styling
Repo
  • Guide

    • Introduction
    • Getting Started
  • Components

    • CataUiAccordion
    • CataUiAccordionItem
    • CataUiAlert
    • CataUiAnchorMenu
    • CataUiBadge
    • CataUiButton
    • CataUiCollapse
    • CataUiDraggable
    • CataUiDropdown
    • CataUiDropover
    • CataUiFileTree
    • CataUiIcon
    • CataUiIconSwitch
    • CataUiInput
    • CataUiInputCheckbox
    • CataUiInputColor
    • CataUiInputDate
    • CataUiInputGroup
    • CataUiInputRadio
    • CataUiInputSearch
    • CataUiInputSelect
    • CataUiMasonry
    • CataUiMasonryTile
    • CataUiLogo
    • CataUiModal
    • CataUiPaginate
    • CataUiProgress
    • CataUiSpinner
    • CataUiStatusLabel
    • CataUiSwitch
    • CataUiTable
    • CataUiTableAG
    • CataUiTableFooter
    • CataUiTabs
    • CataUiTabSwitch
    • CataUiTooltip
  • Styling

    • Colors
    • Icons
    • Typography
    • Utils

CataUiTable

The CataUiTable component provides a flexible data table with features like column sorting, row selection, and customizable cell rendering. It's designed to display tabular data in a structured format with support for various data types.

ID Delivery Name Market Created Date Actions
1The first elementDenmark3/15/2023
2The Second elementIE2/15/2023
3The Third elementUK1/15/2023
4The Last elementUK1/15/2023
5The first elementDenmark3/15/2023
6The Second elementIE2/15/2023
7The Third elementUK1/15/2023
8The Last elementUK1/15/2023
9The Second elementIE2/15/2023
10The Third elementUK1/15/2023
11The Last elementUK1/15/2023
12The Second elementIE2/15/2023
13The Third elementUK1/15/2023
14The Last elementUK1/15/2023
<CataUiTable :rows="rows" :columns="columns" v-model:selected-rows="selectedRows" v-model:sorted-column="sortedColumn" selectable>
    <template #tableCell="{ tableCell, tableColumn, tableRow }">
        <!-- This should be custom, according to your application requirements -->
        <template v-if="tableColumn.type === 'string'">
            {{ tableCell }}
        </template>
        <template v-if="tableColumn.type === 'date'">
            {{ new Date(tableCell).toLocaleDateString() }}
        </template>
        <template v-if="tableColumn.type === 'actions'">
            <CataUiDropdown :actions="tableCell" type="dots" size="small" />
        </template>
    </template>
</CataUiTable>

Tips

Each table cell is the value of the row key that matches the column id row[column.key].

Props

PropDescriptionTypeDefaultRequired
columnsArray of column definitions for the tableArraytrue
fixedHeaderFix the header to the top of the table when scrollingBooleanfalsefalse
rowsArray of data rows to display in the tableArraytrue
selectableEnable row selection with checkboxesBooleanfalsefalse
v-model:selected-rowsArray containing selected row IDsArray[]false
v-model:sorted-columnObject containing sorting configuration for the tableObject{}false

Warning

The v-model value sorted-column MUST be in the following format: { sortOrder: 1, sortColumn: '' }

Where:

  • sortOrder: 1 for ascending, -1 for descending
  • sortColumn: The column key to sort by

Slots

SlotDescription
tableCellScoped slot with access to tableCell, tableColumn, tableRow

Emits

EmitDescription
tableCellClickedEmitted when a table cell is clicked, with object containing id, column, and event
toggleSelectAllEmitted when the select-all checkbox in the header is toggled
toggleSelectRowEmitted when an individual row checkbox is toggled, with row id as parameter

Data Structure Examples

Column Definition

const columns = [
    {
        key: 'id',           // Unique identifier for the column, matches property in row data
        label: 'ID',         // Display label for the column header
        type: 'string',      // Data type (string, date, actions, etc.)
        style: '',           // Optional CSS styles for the column
        sortable: true,      // Whether the column can be sorted
    },
    {
        key: 'market',
        label: 'Market',
        type: 'string',
        style: '',
        sortable: true,
    },
    {
        key: 'created',
        label: 'Created Date',
        type: 'date',
        style: '',
        sortable: true,
    },
    {
        key: 'actions',
        label: 'Actions',
        type: 'actions',
        style: { width: '1%', textAlign: 'right'}, // Can use object for complex styles
        sortable: false,
    }
]

Row Definition

const selectedRows = ref([]);
const sortedColumn = ref({});

const rows = [
    {
        id: '1',                                 // Unique identifier for the row
        name: 'The first element',               // Data properties matching column keys
        market: 'Denmark',
        created: '2023-03-15T15:26:31.597',
        actions: dropdownActions,                // Can contain complex objects
        disableTableRow: true,                   // Optional: disable selection for this row
    },
]

Sorting State

const sortedColumn = ref({
    sortOrder: 1,           // 1 for ascending, -1 for descending
    sortColumn: 'name'      // Key of the column being sorted
});
Prev
CataUiSwitch
Next
CataUiTableAG