Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Order + filter with formatted data

未关闭
#5,045 4 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
react, typescript
领域
frontend

调研方向

从链接的 CodeSandbox 开始,比较使用 cell、accessorFn、getValue 时的列定义,以及 react-table 8.9.3 中的排序和筛选行为。追踪每项操作如何提供原始值和格式化值,然后验证复现的案例可以按原始日期或数字排序,同时按其格式化的显示值进行筛选。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

i need to transform the data to show to the user.

Eg from YYYY-MM-DD to DD/MM/YYYY,
from usd 10.99 to usd 10,99.

Anyway, to order i need to use de original data ( a date or decimal number), to filter i need to use the transformed data or both.
dont exist a property in the row with columnId to return the transformed data (row.original, row.getValue and row.renderValue just return the original data).

i tried to pass the transformed data thru accessorFn: row => formatDate(row.field), but with this approach, i lose the original data in order function, and ordering with transformatted data gives me a wrong ordenation.

how to solve this problem?

Your minimal, reproducible example

https://codesandbox.io/s/nice-ishizaka-s2n6mw?file=/src/App.tsx

Steps to reproduce

create a row
{
header: "name",
accessorKey: "nameKey",
cell: ({getValue}) => formatDate(getValue())
},
// this option i lose the formatted data to filter
or
{
header: "name",
id: 'nameKey',
accessorFn: row => formatDate(row.date),
},
// this option i lose the original data to order

const formatDate = (date: string | Date, format?: string) => {

// console.log("date", date)
format = format || 'dd/MM/yyyy';

return dateFormat(toDate(date), format);

};

Expected behavior

order by original data and filter by transformed data

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

all Operating System and Browsers

react-table version

8.9.3

TypeScript version

5.2.2

Additional context

No response

Terms & Code of Conduct
  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
主要语言
TypeScript
星标
28.5k
派生
3.6k
平均合并
19 小时 40 分钟
30 天内合并 PR
8

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/table 的其他 Issue

查看 TanStack/table 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。