[] = [
+ { id: 'name', title: 'Name', sortable: true, filterable: true },
+ { id: 'email', title: 'Email', sortable: true, filterable: true },
+ { id: 'role', title: 'Role', sortable: true },
]
diff --git a/apps/docs/src/examples/composables/create-data-table/features/FeaturesTable.vue b/apps/docs/src/examples/composables/create-data-table/features/FeaturesTable.vue
index 8274a804d..82fcb1a3d 100644
--- a/apps/docs/src/examples/composables/create-data-table/features/FeaturesTable.vue
+++ b/apps/docs/src/examples/composables/create-data-table/features/FeaturesTable.vue
@@ -4,8 +4,6 @@
import { employees } from './data'
const table = createDataTable({
- items: employees,
- columns,
groupBy: 'department',
openAll: true,
mandate: true,
@@ -15,14 +13,17 @@
pagination: { itemsPerPage: 20 },
})
- function sortIcon (key: string) {
- const dir = table.sort.direction(key)
+ table.columns.onboard(columns)
+ table.onboard(employees.map(value => ({ id: value.id, value })))
+
+ function arrow (id: string) {
+ const dir = table.sort.direction(id)
if (dir === 'asc') return '↑'
if (dir === 'desc') return '↓'
return ''
}
- function formatSalary (value: number) {
+ function format (value: number) {
return `$${value.toLocaleString()}`
}
@@ -68,13 +69,13 @@
|
{{ col.title }}
- {{ sortIcon(col.key) }}
+ {{ arrow(col.id) }}
|
@@ -85,7 +86,7 @@
class="bg-surface-tint cursor-pointer hover:bg-surface-variant transition-colors"
@click="table.grouping.toggle(group.key)"
>
-
+ |
{{ table.grouping.isOpen(group.key) ? '−' : '+' }}
{{ group.key }}
({{ group.items.length }})
@@ -111,7 +112,7 @@
| {{ item.name }} |
{{ item.department }} |
- {{ formatSalary(item.salary) }} |
+ {{ format(item.salary) }} |
[] = [
- { key: 'name', title: 'Name', sortable: true, filterable: true },
- { key: 'department', title: 'Department', sortable: true },
+export const columns: DataTableColumnTicketInput[] = [
+ { id: 'name', title: 'Name', sortable: true, filterable: true },
+ { id: 'department', title: 'Department', sortable: true },
{
- key: 'salary',
+ id: 'salary',
title: 'Salary',
sortable: true,
filterable: true,
@@ -17,5 +17,5 @@ export const columns: DataTableColumn[] = [
return String(value).includes(query)
},
},
- { key: 'active', title: 'Status', sortable: true },
+ { id: 'active', title: 'Status', sortable: true },
]
diff --git a/apps/docs/src/examples/composables/create-data-table/server/ServerTable.vue b/apps/docs/src/examples/composables/create-data-table/server/ServerTable.vue
index aa0e4b446..ca42033f0 100644
--- a/apps/docs/src/examples/composables/create-data-table/server/ServerTable.vue
+++ b/apps/docs/src/examples/composables/create-data-table/server/ServerTable.vue
@@ -1,48 +1,43 @@
|