Using multiple accessor properties
See original GitHub issueWhat version of React-Table are you using?
- 6.7.4
What bug are you experiencing, or what feature are you proposing?
Unable to have multiple accessor
s when rendering a column. Need a way where I can take in multiple properties, run a function check the length of the argument and render the UI accordingly.
What are the steps to reproduce the issue?
Data:
{
name: "Sarah",
prop1: {edges: [node:{id: 1}, node: {id: 2}]},
groupProp1: {edges: [node:{id: 1}],
groupProp2: {edges: [node:{id: 1}, node:{id: 2}]},
}
Render Columns:
const columns=[
{
Header: 'Name',
accessor: 'name'
},
{
Header: 'Prop1',
accessor: 'prop1'
Cell: props => <div>{renderFunc(props.value, arg)}</div>
}
{
Header: 'Group Prop',
accessor: ['groupProp1', 'groupProp2'] <<<<<< Need to access multiple properties
Cell: props => <div>{renderFunc(props.value, arg)}</div> <<<<<< Pass in those properties
}
]
What I need to do is access both groupProp1 and groupProp2 and pass that into my renderFunc
to grab the edges.length
and render elements accordingly. So far I haven’t found a way where you can pass in multiple properties in the accessor. Looking through the documentation I don’t see any examples of this
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Using multiple accessor properties · Issue #648 · TanStack/table
An accessor can be a function that gets the whole row. Cell gets more in the props than just the value (there is...
Read more >Adding multiple data to a column in react-table - Stack Overflow
Where the accessor is Product I want to show both the name and description (I'll style them to stack with different font sizes)...
Read more >Properties With Multiple Access Modifiers in C# 2.0 - Dotnet Stuff
In C# the member variables will be exposed by means of Properties. The get and set portions of a property are called accessors....
Read more >Property accessors - JavaScript - MDN Web Docs - Mozilla
Property accessors provide access to an object's properties by using the dot notation or the bracket notation.
Read more >Using Properties - C# Programming Guide - Microsoft Learn
To the implementer of a class, a property is one or two code blocks, representing a get accessor and/or a set accessor. The...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Basically, as I understand it, the value in the
accessor
doesn’t even matter if the cell is to be filled with multiple values or different properties in the data… This is very weird.Example:
An
accessor
can be a function that gets the whole row.Cell
gets more in theprops
than just thevalue
(there is arow
andoriginal
- which contain row information). Check the doco. Also please consider joining #react-table on Slack (badge at the top of the README in the doco) for these implementation type questions. Thanks.