Skip to content

Commit ec23eb0

Browse files
committed
added updateSort emit and its type declaration
1 parent 9f7036a commit ec23eb0

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/components/DataTable.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ onMounted(() => {
314314
const emits = defineEmits([
315315
'clickRow',
316316
'expandRow',
317+
'updateSort',
317318
'update:itemsSelected',
318319
'update:serverOptions',
319320
]);
@@ -353,6 +354,7 @@ const {
353354
sortBy,
354355
sortType,
355356
updateServerOptionsSort,
357+
emits
356358
);
357359
358360
const {

src/hooks/useHeaders.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
ref, Ref, computed, ComputedRef, WritableComputedRef,
33
} from 'vue';
44
import type { Header, SortType } from '../types/main';
5-
import type { ServerOptionsComputed, HeaderForRender, ClientSortOptions } from '../types/internal';
5+
import type { ServerOptionsComputed, HeaderForRender, ClientSortOptions, EmitsEventName } from '../types/internal';
66

77
export default function useHeaders(
88
checkboxColumnWidth: Ref<number>,
@@ -21,6 +21,7 @@ export default function useHeaders(
2121
sortBy: Ref<string>,
2222
sortType: Ref<SortType>,
2323
updateServerOptionsSort: (newSortBy: string, newSortType: SortType | null) => void,
24+
emits: (event: EmitsEventName, ...args: any[]) => void,
2425
) {
2526
const hasFixedColumnsFromUser = computed(() => headers.value.findIndex((header) => header.fixed) !== -1);
2627
const fixedHeadersFromUser = computed(() => {
@@ -113,6 +114,7 @@ export default function useHeaders(
113114
sortDesc: newSortType === 'desc',
114115
};
115116
}
117+
emits("updateSort", newSortType, newSortBy)
116118
};
117119

118120
return {

src/types/internal.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ export type ClientSortOptions = {
2323

2424
export type MultipleSelectStatus = 'allSelected' | 'noneSelected' | 'partSelected'
2525

26-
export type EmitsEventName = 'clickRow' | 'expandRow' | 'update:itemsSelected' | 'update:serverOptions'
26+
export type EmitsEventName = 'clickRow' | 'expandRow' | 'updateSort' | 'update:itemsSelected' | 'update:serverOptions'

0 commit comments

Comments
 (0)