Skip to content

Commit

Permalink
feat: useGlobalFilter exclude columns
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanmylee committed May 11, 2022
1 parent d91f3fb commit 9131c8e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/plugins/useGlobalFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface GlobalFilterState<Item> {
}

export interface GlobalFilterColumnOptions {
disable?: boolean;
exclude?: boolean;
getFilterValue?: (value: unknown) => string;
}

Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/routes/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
sort: {
disable: true,
},
globalFilter: {
exclude: true,
},
},
}),
],
Expand Down

0 comments on commit 9131c8e

Please sign in to comment.