我正在使用@Equify/react-datasheet-grid开发一个基于React的网站。当我使用render()函数时,我不能改变单元格值。我还检查了这个问题(React Input Type not editable)。但是我不能解决我的问题。
下面是我的代码:
columns
const columns = [
textColumn({ title: 'Kulak No',
width: 1,
minWidth: 200,
key: 'identityNumber',
render: d=>renderStyle(d.rowData['identityNumber'], d.rowIndex)})
]renderStyle
const renderStyle = (value, rowIndex) => {
return (<input className='dsg-input' defaultValue={value} style={{"pointerEvents": "none", "backgroundColor": "rgba(199, 184, 26, 0.6)"}}>);如果有任何帮助,我将不胜感激。附言:请考虑到我是一个新的反应。
发布于 2021-01-20 13:27:37
我在@Equify/react-datasheet-grid上打开了这一期。你可以从链接中看到。我找到了解决方案:
const columns = [
textColumn({ title: 'Kulak No',
width: 1,
minWidth: 200,
key: 'identityNumber',
render: ({rowData, rowIndex, columnIndex, setRowData}) => renderStyle(rowData, rowIndex, columnIndex, setRowData), d.rowIndex)})
]const renderStyle = (rowData, rowIndex, columnIndex, setRowData) => {
let column = getKeyByValue(columnsIndexes, columnIndex);
return (
<input className='dsg-input'
defaultValue={rowData[column]}
onChange={(e) => setRowData({...rowData, column: e.target.value})}
style={{'backgroundColor': 'aqua'}}>
</input>);
}https://stackoverflow.com/questions/65790407
复制相似问题