使用reactjs中的materialtable在列中自动生成当前日期
auto-generated current date in a column using materialtable in reactjs
当我想在材料表中添加新行时,我需要字段日期必须自动生成并采用当前日期的值,并且该日期不能在更新或插入中编辑
这是我的解决方案,但它不起作用
columns: [
{
...,
title: 'date',
field: 'fieldDate',
type: 'date',
default: new Date()
},
...]
根据文档,您可以使用 initialEditValue
设置新行的值:https://material-table.com/#/docs/all-props
您的列定义为:
columns: [
{
...,
title: 'date',
field: 'fieldDate',
type: 'date',
initialEditValue: new Date()
},
...
]
当我想在材料表中添加新行时,我需要字段日期必须自动生成并采用当前日期的值,并且该日期不能在更新或插入中编辑
这是我的解决方案,但它不起作用
columns: [
{
...,
title: 'date',
field: 'fieldDate',
type: 'date',
default: new Date()
},
...]
根据文档,您可以使用 initialEditValue
设置新行的值:https://material-table.com/#/docs/all-props
您的列定义为:
columns: [
{
...,
title: 'date',
field: 'fieldDate',
type: 'date',
initialEditValue: new Date()
},
...
]