I have multiple DataGrid
tables in my project, but I cannot figure out what is wrong with this one.
I have created a codesandbox example of my problem. If anyone could help I would appreciate it very much.
It is probably a dumb mistake
CodePudding user response:
You have declared a field with name license
2 times.
Changing to e.g.
{
field: "licence",
headerName: "Licence start",
flex: 1,
valueGetter: (params) =>
`${moment(params.row.licence.startsAt).format("DD.MM.YYYY") || ""}`
},
{
field: "licence2",
headerName: "Licence ends at",
flex: 1,
valueGetter: (params) =>
`${moment(params.row.licence.endsAt).format("DD.MM.YYYY") || ""}`
},
will solve the problem
CodePudding user response:
so the error is because you’re having those bothe fileds at the time (same name),
{
field: "licence",
headerName: "Licence start",
flex: 1,
valueGetter: (params) =>
`${moment(params.row.licence.startsAt).format("DD.MM.YYYY") || ""}`
},
{
field: "licence",
headerName: "Licence ends at",
flex: 1,
valueGetter: (params) =>
`${moment(params.row.licence.endsAt).format("DD.MM.YYYY") || ""}`
},
removing one of them will solve your issue , you need to make sure how to access the date in other way