reactable icon indicating copy to clipboard operation
reactable copied to clipboard

Interactive Drop-down for specific columns

Open coppertank opened this issue 1 year ago • 1 comments

Online I found this tutorial that explains how to create an interactive filter with reactable. The result is the following:

Screenshot 2024-09-28 231139

I need to get a similar result, the difference is that I don't need to create a filter, but a drop-down menu to select a weight for which the corresponding column needs to be multiplied. An example is this:

Screenshot 2024-09-28 012544

In this example, only the columns with numeric values ​​have the drop-down menu, through which you can select a weight and multiply each value in the column by that weight, updating the table in real time.

Is there a way to achieve this in reactable?

coppertank avatar Sep 28 '24 21:09 coppertank

Custom metadata would be one way to do this if the multiplied value is purely for display, i.e. all filtering/sorting would still be done on the original raw value.

Here's an example of using custom metadata to multiply and reformat column values, for a currency conversion: https://glin.github.io/reactable/articles/examples.html#custom-meta-rendering

If you want the dropdown in the filter slot, you can reference the custom filter input examples but just use the inputs to run Reactable.setMeta() instead of Reactable.setFilter().

glin avatar Oct 07 '24 03:10 glin