Skip to content

Commit

Permalink
Add selectAll event
Browse files Browse the repository at this point in the history
  • Loading branch information
HC200ok committed Mar 21, 2023
1 parent d35c972 commit aba81cb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"author": "HC200ok",
"description": "A customizable and easy-to-use data table component made with Vue.js 3.x.",
"private": false,
"version": "1.5.40",
"version": "1.5.41",
"types": "./types/main.d.ts",
"license": "MIT",
"files": [
Expand Down
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<!-- <ServerSideMode /> -->
<ServerSideMode />
<br><br>
<ClientMode />
<!-- <ClientMode /> -->
<br><br>
<!-- <ExpandLoading/> -->
</template>
Expand Down
1 change: 1 addition & 0 deletions src/components/DataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ const emits = defineEmits([
'update:serverOptions',
'updatePageItems',
'updateTotalItems',
'selectAll'
]);
const isMultipleSelectable = computed((): boolean => itemsSelected.value !== null);
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useTotalItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export default function useTotalItems(

const toggleSelectAll = (isChecked: boolean): void => {
selectItemsComputed.value = isChecked ? totalItems.value : [];
if (isChecked) emits('selectAll');
};

const toggleSelectItem = (item: Item):void => {
Expand Down
6 changes: 6 additions & 0 deletions src/modes/ServerSide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
border-cell
multi-sort
@update-sort="updateSort"
@select-all="selectAll"
>
<template #expand="item">
<div style="padding: 15px">
Expand Down Expand Up @@ -134,6 +135,10 @@ export default defineComponent({
const loading = ref(false);
const selectAll = () => {
console.log("sssss")
}
const loadFromServer = async () => {
loading.value = true;
const {
Expand Down Expand Up @@ -215,6 +220,7 @@ export default defineComponent({
updatePage,
bodyRowClassName,
updateSort,
selectAll,
};
},
Expand Down
2 changes: 1 addition & 1 deletion src/types/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export type ClickEventType = 'single' | 'double'
export type MultipleSelectStatus = 'allSelected' | 'noneSelected' | 'partSelected'

// eslint-disable-next-line max-len
export type EmitsEventName = 'clickRow' | 'selectRow' | 'deselectRow' | 'expandRow' | 'updateSort' | 'update:itemsSelected' | 'update:serverOptions' | 'updateFilter' | 'updatePageItems' | 'updateTotalItems'
export type EmitsEventName = 'clickRow' | 'selectRow' | 'deselectRow' | 'expandRow' | 'updateSort' | 'update:itemsSelected' | 'update:serverOptions' | 'updateFilter' | 'updatePageItems' | 'updateTotalItems' | 'selectAll'

0 comments on commit aba81cb

Please sign in to comment.