We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EditableProTable表格中 当我修改“车型”下拉框的时候进行“单价”输入框的修改不生效
import { EditableFormInstance, EditableProTable, ProColumns } from '@ant-design/pro-components'; import { memo, useImperativeHandle, useRef, useState } from 'react'; type VehicleModelProps = { cRef?: any; }; type DataSourceType = { id: React.Key; children?: DataSourceType[]; type?: string; count?: number; price?: number; amount?: number; }; const defaultData: DataSourceType[] = new Array(1).fill(1).map((_, index) => { return { id: (Date.now() + index).toString(), type: '1', count: 1, price: 1, amount: 1, }; }); const VehicleModel: React.FC<VehicleModelProps> = ({ cRef }) => { const editableFormRef = useRef<EditableFormInstance>(); const [editableKeys, setEditableRowKeys] = useState<React.Key[]>(() => defaultData.map((item) => item.id), ); const [dataSource, setDataSource] = useState<readonly DataSourceType[]>(() => []); useImperativeHandle(cRef, () => ({}), []); const columns: ProColumns<DataSourceType>[] = [ { title: '车型', dataIndex: 'type', width: 200, valueType: 'select', valueEnum: { '1': { text: '车型1', }, '2': { text: '车型2', }, }, fieldProps: (_, { rowIndex }) => { return { onSelect: () => { editableFormRef.current?.setRowData?.(rowIndex, { price: 10 }); }, }; }, }, { title: '数量', dataIndex: 'count', width: 100, valueType: 'digit', fieldProps: { min: 1, precision: 0, }, }, { title: '单价', dataIndex: 'price', width: 100, valueType: 'digit', fieldProps: { min: 0, precision: 2, }, }, { title: '总价', readonly: true, dataIndex: 'amount', width: 120, }, { title: '操作', valueType: 'option', width: 60, render: () => { return null; }, }, ]; console.log('dataSource', dataSource); return ( <EditableProTable<DataSourceType> editableFormRef={editableFormRef} columns={columns} rowKey="id" scroll={{ x: 630, }} value={dataSource} onChange={setDataSource} recordCreatorProps={{ newRecordType: 'dataSource', record: () => ({ id: Date.now(), }), }} editable={{ type: 'multiple', editableKeys, actionRender: (row, config, defaultDoms) => { return [defaultDoms.delete]; }, onValuesChange: (record, recordList) => { setDataSource(recordList); }, onChange: setEditableRowKeys, form: editableFormRef.current, }} /> ); }; export default memo(VehicleModel);
setRowData能正常修改数据
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
升级版本就可以了
No branches or pull requests
🐛 bug 描述
EditableProTable表格中 当我修改“车型”下拉框的时候进行“单价”输入框的修改不生效
📷 复现步骤 | Recurrence steps
🏞 期望结果 | Expected results
setRowData能正常修改数据
💻 复现代码 | Recurrence code
© 版本信息
🚑 其他信息
The text was updated successfully, but these errors were encountered: