Add new prop to ignore deep nested accessorKey
#5977
Unanswered
davidyeiser
asked this question in
Ideas
Replies: 1 comment 3 replies
-
If anyone wants to try it out: https://www.npmjs.com/package/react-table-with-skip-accessor-key-dot-notation Use when defining table headers: {
accessorKey: "example.with.dots",
header: "Example",
ignoreDeepNested: true,
} Data like so: {
"example.with.dots": "data"
} Would output:
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We’re using TanStack/table in our React project and it works great. The documentation is easy to follow and the feature set is wonderful. Much thanks to those who have worked on it!
I've run into a situation where it seems the “best” option is adding a small, new feature.
Situation
We have data in our product that is submitted as JSON and we provide a table view on top of that data. There is no enforced schema on the JSON data and it also varies in size (a file may be 1kb or 100MB).
At times, the JSON data will have object keys with dots in them, but they are just names and have no association with how to access the data. For example, something like this:
The tables are built dynamically and the
accessorKey
is defined by the object property. So theaccessorKey
for the first column in the data above would beL(region)[S.Arkansas]
but the lookup fails as expected because of the.
that is present.One option would be to run all the object properties keys through a sanitation function, but I don’t really want to add extra processing when the data is on the large end.
Proposed
The new feature would be adding an optional
ignoreDeepNested
property (or whatever the best name for it would be) that could be passed to the Column Definition and if true the data accessor function would ignore the dot notation and just treat it as a flat string lookup.I ran a quick test locally and it seemed feasible with minimal changes, but I could be missing some things. Here are the changes I made:
table-core/src/core/column.ts
I updated the
AccessorKeyColumnDefBase
type intable-core/src/types.ts
and then I added this quick test to run locally:It passes when
ignoreDeepNested: true
is present, and fails when it’s not.Beta Was this translation helpful? Give feedback.
All reactions