【发布时间】:2021-10-19 20:04:30
【问题描述】:
我想在添加行可编辑打开之前执行一个函数。
在此 UI 打开之前,我想执行一个功能。 (如console.log('Hello'))
这是我目前的材料表代码。
<MaterialTable
title="Timesheet"
columns={columns}
data={DataArray}
icons={tableIcons}
editable={{
onRowAddCancelled: rowData => console.log('Row adding cancelled'),
onRowUpdateCancelled: rowData => console.log('Row editing cancelled'),
onRowAdd: newData =>
new Promise((resolve, reject) => {
setTimeout(() => {
// add row
}, 1000);
}),
}}
options={{
actionsColumnIndex: -1,
addRowPosition: "first",
search:false,
exportButton: true,
}}
/>
【问题讨论】:
-
什么不起作用?能详细点吗?
-
好的。顶部有一个 + 按钮,可让我添加行。但是当我单击按钮时,我希望它执行一个功能(可能是 console.log('Hello') )然后执行添加行功能。够清楚吗?
标签: javascript reactjs material-table