From 8ee84ef37a6b17d293a54ff9455d86df5e343beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=B3pez=20C?= Date: Tue, 18 Jul 2023 17:21:32 -0500 Subject: [PATCH 01/32] Sort event Table.vue Emit event Sort for capture this event and filter data in backend --- src/runtime/components/data/Table.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/runtime/components/data/Table.vue b/src/runtime/components/data/Table.vue index 9750c2dfe1..635b89213b 100644 --- a/src/runtime/components/data/Table.vue +++ b/src/runtime/components/data/Table.vue @@ -137,7 +137,7 @@ export default defineComponent({ default: () => appConfig.ui.table } }, - emits: ['update:modelValue'], + emits: ['update:modelValue',"sort"], setup (props, { emit, attrs }) { // TODO: Remove const appConfig = useAppConfig() @@ -199,6 +199,7 @@ export default defineComponent({ } else { sort.value = { column: column.key, direction: column.direction || 'asc' } } + emit("sort",sort.value); } function onSelect (row) { From 897f00b2b3c83171aee2b020d3301606e92ad93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=B3pez=20C?= Date: Thu, 20 Jul 2023 12:32:13 -0500 Subject: [PATCH 02/32] Update Table.vue this could also work --- src/runtime/components/data/Table.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/runtime/components/data/Table.vue b/src/runtime/components/data/Table.vue index 635b89213b..b60a646f02 100644 --- a/src/runtime/components/data/Table.vue +++ b/src/runtime/components/data/Table.vue @@ -11,6 +11,8 @@ , default: () => ({}) }, + fnSort:{ + type: [ Function], + }, sortButton: { type: Object as PropType>, default: () => appConfig.ui.table.default.sortButton @@ -188,6 +193,10 @@ export default defineComponent({ } function onSort (column: { key: string, direction?: 'asc' | 'desc' }) { + if(props.fnSort){ + sort.value.column=column.key + await props.fnSort(column); + } if (sort.value.column === column.key) { const direction = !column.direction || column.direction === 'asc' ? 'desc' : 'asc' @@ -199,7 +208,6 @@ export default defineComponent({ } else { sort.value = { column: column.key, direction: column.direction || 'asc' } } - emit("sort",sort.value); } function onSelect (row) { From 33a4f77405133e6988ca96c5f4e956e093112df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=B3pez=20C?= Date: Thu, 20 Jul 2023 12:33:20 -0500 Subject: [PATCH 03/32] Update Table.vue Remove emit sort --- src/runtime/components/data/Table.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/components/data/Table.vue b/src/runtime/components/data/Table.vue index b60a646f02..21ef8e101d 100644 --- a/src/runtime/components/data/Table.vue +++ b/src/runtime/components/data/Table.vue @@ -142,7 +142,7 @@ export default defineComponent({ default: () => appConfig.ui.table } }, - emits: ['update:modelValue',"sort"], + emits: ['update:modelValue'], setup (props, { emit, attrs }) { // TODO: Remove const appConfig = useAppConfig() From d5fd7cf18e56cc0003e403a3d51d894d612aa2db Mon Sep 17 00:00:00 2001 From: CLOPEZPRO Date: Thu, 20 Jul 2023 17:24:40 -0500 Subject: [PATCH 04/32] test DATAtable from API jsonplaceholder --- playground/app.vue | 82 +++++++++++++++++++++++++-- src/runtime/components/data/Table.vue | 22 ++++--- 2 files changed, 91 insertions(+), 13 deletions(-) diff --git a/playground/app.vue b/playground/app.vue index 5c8f5a2b52..b0fd39ffd1 100644 --- a/playground/app.vue +++ b/playground/app.vue @@ -5,15 +5,89 @@ Welcome to the playground! -

- Try your components here! -

+ + + + +
+ +
-