glittershark / reactable

Fast, flexible, and simple data tables in React
glittershark.github.io/reactable
MIT License
1.51k stars 223 forks source link

Can the value of a column be a function? #360

Open Dashman99 opened 7 years ago

Dashman99 commented 7 years ago

For example if I have a column called Number and a column Total, can I create a column which displays the percentage of total PercentOfTotal ?

Something like this, assuming I had a function called getPercentOfTotal(a, b)

<Thead>
   <Th column="Number">Number</Th>
   <Th column="Total">Total</Th>
   <Th column={getPercentOfTotal(Number, Total)}>PercentOfTotal</Th>
</Thead>
brinley commented 7 years ago

Cant see any reason a column is dynamic but I'm sure it would work as long as your function returns the same string as the corresponding Td column

andrewlorenz commented 7 years ago

this doesn't work. Shame you say you can't see any reason for this, I can ! It would be great if the columns array / Th had an optional value= parameter, to supply a function that can be called with that column's row data values to apply (say) formatting, or to translate, or to compute a value.