From 9131c8e3af43da5d02879c6d9ee64a9227c4a806 Mon Sep 17 00:00:00 2001 From: Bryan Lee Date: Wed, 11 May 2022 22:15:57 +0800 Subject: [PATCH] feat: useGlobalFilter exclude columns --- src/lib/plugins/useGlobalFilter.ts | 5 ++++- src/routes/index.svelte | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/plugins/useGlobalFilter.ts b/src/lib/plugins/useGlobalFilter.ts index c8bcb4b..8aa3f28 100644 --- a/src/lib/plugins/useGlobalFilter.ts +++ b/src/lib/plugins/useGlobalFilter.ts @@ -14,7 +14,7 @@ export interface GlobalFilterState { } export interface GlobalFilterColumnOptions { - disable?: boolean; + exclude?: boolean; getFilterValue?: (value: unknown) => string; } @@ -61,6 +61,9 @@ export const useGlobalFilter = const _filteredRows = rows.filter((row) => { // An array of booleans, true if the cell matches the filter. const cellMatches = Object.values(row.cellForId).map((cell) => { + if (columnOptions[cell.id]?.exclude) { + return false; + } const isHidden = row.cells.find((c) => c.id === cell.id) === undefined; if (isHidden && !includeHiddenColumns) { return false; diff --git a/src/routes/index.svelte b/src/routes/index.svelte index 31866e3..f21dbee 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -69,6 +69,9 @@ sort: { disable: true, }, + globalFilter: { + exclude: true, + }, }, }), ],