Repository navigation
Replies: 1 comment
|
You can keep the underlying values as booleans. In v8, For the linked example, add an eligibility override and map boolean values inside the filter: getColumnCanGlobalFilter: () => true,
globalFilterFn: (row, columnId, filterValue) => {
const raw = row.getValue(columnId);
const text = typeof raw === 'boolean'
? (raw ? 'Online' : 'Offline')
: String(raw ?? '');
return text.toLowerCase().includes(String(filterValue).toLowerCase());
},Here, I checked the linked reproduction and tested its data with the real table core in 8.21.2 and 8.21.3. Searching See |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi all!
I've recently been building some tables with tanstack table and I've come across some situations where I have a column with boolean values and I want to include that (transformed) in the global filter.
Simple reproduction: https://stackblitz.com/edit/vitejs-vite-vej6boy5?file=src%2Fmain.tsx
Line in tanstack table that is causing it (I think):
table/packages/table-core/src/features/GlobalFiltering.ts
Line 116 in db745af
Goal
I'm trying to have a column of boolean type which is globally searchable using some transforming logic. I want to transform the boolean to a string when searching/somewhere else if possible and pass that to the global filter.
Possible solution
I could just store the transformed string in the column instead of the boolean (eg. "Online"/"Offline" instead of online: true/false). I would like to avoid this if possible, but if using strings is preferred in tanstack table then let me know.
All reactions