ant-design / pro-components

🏆 Use Ant Design like a Pro!
https://pro-components.antdigital.dev
MIT License
4.04k stars 1.29k forks source link

数据更新 页面不更新 #8367

Open whqgo opened 2 weeks ago

whqgo commented 2 weeks ago
const columns = useRef<any>([
    {
        key: 'sort',
        dataIndex: 'key',
        editable: false,
        width: 30,
    },
    {
        title: '序号',
        key: 'serial',
        dataIndex: 'serial',
        // editable: false,
        width: '60px',
        // render: (_: any, __: any, index: number) => index + 1, // 使用 index + 1 作为序号值
    },
    {
        title: '字段名称',
        dataIndex: 'lable',
        width: '30%',
    },
    {
        title: '是否显示',
        dataIndex: 'visible',
        valueType: 'checkbox',
        width: '30%',
        renderFormItem: (_: any, itemRecord: any) => {
            // 自定义复选框的渲染
            return <Checkbox onChange={(e) => {
                console.log(itemRecord, "===record===");

                // record
                setDataSource((dataSource: any) => {
                    let _dataSource = cloneDeep(dataSource)
                    let recordfind = _dataSource.find((f: any) => f.id === itemRecord.record.id)
                    recordfind.visible = false
                    console.log(_dataSource, "===_dataSource====");

                    return _dataSource
                })

            }} checked={itemRecord.record.visible}>{itemRecord.record.visible}</Checkbox>
        }
    },

    {
        title: '操作',
        valueType: 'option',
        width: 250,
        render: () => {
            return null;
        },
    },
])

我修改了 数据 但是页面并没有更新

whqgo commented 2 weeks ago
headerTitle="" columns={columns.current} rowKey="id" scroll={{ x: 960, }} value={dataSource} onChange={(e)=>{ console.log(e,"=====EditableProTable======onChange======="); debugger setDataSource(()=>e) }} recordCreatorProps={false} // recordCreatorProps={{ // newRecordType: 'dataSource', // // position: 'top', // // 设置按钮文案 // creatorButtonText: '新增一行', // record: () => ({ // id: Date.now(), // }), // }} // toolBarRender={() => { // return [ // , // ]; // }} editable={{ type: 'multiple', editableKeys, actionRender: (row, config, defaultDoms) => { return [defaultDoms.delete]; }, onValuesChange: (record, recordList) => { console.log(record, "==onValuesChange=record==="); console.log(recordList, "==onValuesChange=recordList==="); setDataSource((data)=>{ return data }); }, onChange: setEditableRowKeys, }} // pagination={false} components={{ body: { row: RowH, }, }} />