chore: griddy work
This commit is contained in:
@@ -2,6 +2,7 @@ import type { ColumnDef } from '@tanstack/react-table'
|
||||
|
||||
import type { GriddyColumn, SelectionConfig } from './types'
|
||||
|
||||
import { createOperatorFilter } from '../features/filtering'
|
||||
import { DEFAULTS, SELECTION_COLUMN_ID, SELECTION_COLUMN_SIZE } from './constants'
|
||||
|
||||
/**
|
||||
@@ -38,10 +39,21 @@ export function mapColumns<T>(
|
||||
meta: { griddy: col },
|
||||
minSize: col.minWidth ?? DEFAULTS.minColumnWidth,
|
||||
size: col.width,
|
||||
// For function accessors, TanStack can't auto-detect the sort type, so default to 'auto'
|
||||
sortingFn: col.sortFn ?? (isStringAccessor ? undefined : 'auto') as any,
|
||||
}
|
||||
if (col.filterFn) def.filterFn = col.filterFn
|
||||
|
||||
// For function accessors, TanStack can't auto-detect the sort type, so provide a default
|
||||
if (col.sortFn) {
|
||||
def.sortingFn = col.sortFn
|
||||
} else if (!isStringAccessor && col.sortable !== false) {
|
||||
// Use alphanumeric sorting for function accessors
|
||||
def.sortingFn = 'alphanumeric'
|
||||
}
|
||||
|
||||
if (col.filterFn) {
|
||||
def.filterFn = col.filterFn
|
||||
} else if (col.filterable) {
|
||||
def.filterFn = createOperatorFilter()
|
||||
}
|
||||
return def
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user