You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{renderCellDate}from"../renderCell";exportconstcolumnsDefinition=[{accessorKey: "person_forename",header: "Vorname",//simple recommended way to define a columnenableHiding: false,//disable a feature for this columntype: String,// for importFileXLSXrequired: true,// for importFileXLSXwidth: 15,// for exportFileXLSX},//...{// accessorKey: "person_dateofbirth",id: "person_dateofbirth",// enableEditing: false,header: "Geburtstag",accessorFn: (row)=>accessorFnDate(row,"person_dateofbirth"),// https://www.material-react-table.com/docs/guides/data-columns#custom-cell-renderCell: renderCellDate,type: Date,required: false,width: 15,},//...];
this way my view is rendered as i like it - but the date-format is hardcoded in the renderCell.js file :-(
in the future i like to add a ui so the user can select how he wants to show up things..
i have split out the renderCellDate as i use it in a bunch of different columnsDefinition...
i found that in mui it seems the way to do things is to use the LocalizationProvider with an library adapter:
so i added this example with the Luxon adapter - and the example worked.
but i have no idea how to get this formatting now into my rendering function / columnsDefinition...
i think i need somehow a pointer to the Luxon instance -
so i can use this for formatting..
it also seems to be possible to do some localization via the ThemeProvider thing (i used it for the automatic dark-mode)
has anybody any ideas or tips for this?
i think iam missing something very basic...
sunny greetings
stefan
edit: fixed misuse of accessorFn to Cell for rendering
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello community,
i am experimenting with localization support for my table view.
currently i have a custom cell rendering in my columnsDefinition like this:
renderCell.js
columnsDefinition.js
this way my view is rendered as i like it - but the date-format is hardcoded in the
renderCell.js
file :-(in the future i like to add a ui so the user can select how he wants to show up things..
i have split out the
renderCellDate
as i use it in a bunch of different columnsDefinition...i found that in mui it seems the way to do things is to use the
LocalizationProvider
with an library adapter:so i added this example with the
Luxon
adapter - and the example worked.but i have no idea how to get this formatting now into my rendering function / columnsDefinition...
i think i need somehow a pointer to the Luxon instance -
so i can use this for formatting..
it also seems to be possible to do some localization via the ThemeProvider thing (i used it for the automatic dark-mode)
has anybody any ideas or tips for this?
i think iam missing something very basic...
sunny greetings
stefan
edit: fixed misuse of
accessorFn
toCell
for renderingBeta Was this translation helpful? Give feedback.
All reactions