[DataGrid] Accept row
argument in valueFormatter
#8836
Labels
breaking change
component: data grid
This is the name of the generic UI component, not the React module!
dx
Related to developers' experience
enhancement
This is not a bug, nor a new feature
performance
plan: Premium
Impact at least one Premium user
v7.x
Duplicates
Latest version
Summary 💡
In the DataGrid component, this is how we can declare a column:
In this example, I am using
renderCell
to display the formatted value on the table for the followingtime
object:I am parsing the data from the server to be already formatted on my components.
But now I want to export this data as CSV and I want to display the formatted value on the file. For this, I have to use
valueFormatter
to format the value.This is how I can get the formatted value using
valueFormatter
:I think a better approach would be just to make
row
available on thevalueFormatter
paramsI believe that many developers are already parsing and formatting the data from the server to be already formatted when the data is used on components. This has the obvious advantage of only needing to format once instead of on every single component where the data is needed. Another advantage is, if we add too much format logic to the
valueFormatter
function, it can be bad performance-wise because that logic will run on every render (I may be wrong).In short, my suggestion is to make
row
argument available on thevalueFormatter
function :)Examples 🌈
Expected behavior
Use
row
argument invalueFormatter
Motivation 🔦
I was displaying the formatted value on the DataGrid using
renderCell
but the requirement to be able to export the data from the DataGrid was raised.With this requirement, I have to use
valueFormatter
instead to display the formatted value on the exported file.After converting to
valueFormatter
, I faced the problem where thevalueFormatter
function doesn't make much sense if I am not able to access therow
to get the formatted value that I have previously formatted.Order ID 💳 (optional)
54728
The text was updated successfully, but these errors were encountered: