Skip to content

Expose a getUniqueValues on column #4773

Answered by dd-jonas
dd-jonas asked this question in Ideas
Discussion options

You must be logged in to vote

I had changed my code so that I didn't need to get the unique values of a column. Instead, I handled this outside of Tanstack Table by creating an array of unique values manually based on the data.

However, there is now the option in Tanstack Table to add custom features. Your approach is fine, but here's a more native way to do it. (See the custom features docs: https://tanstack.com/table/latest/docs/guide/custom-features#createcolumn).

file: useTable.ts

import { useReactTable, getCoreRowModel, type TableOptions } from '@tanstack/react-table';

// A wrapper around useReactTable with some defaults, including the custom features.
// (This is not necessary if you call useReactTable in a sin…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@dd-jonas
Comment options

Answer selected by dd-jonas
@jhyland87
Comment options

@jhyland87
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants