forked from ddrilling/asb_cloud_front
fix, not tested EditableTable
This commit is contained in:
parent
056642f705
commit
139f73e968
@ -1,6 +1,6 @@
|
||||
import { Form, Input, Table, Button, Popconfirm } from "antd"
|
||||
import { EditOutlined, SaveOutlined, PlusOutlined, CloseCircleOutlined, DeleteOutlined } from '@ant-design/icons'
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
const newRowKeyValue = 'newRow'
|
||||
|
||||
@ -48,6 +48,10 @@ export const EditableTable = ({
|
||||
const [data, setData] = useState(dataSource?? [])
|
||||
const [editingKey, setEditingKey] = useState('')
|
||||
|
||||
useEffect(()=>{
|
||||
setData(dataSource??[])
|
||||
},[dataSource])
|
||||
|
||||
const isEditing = (record) => record.key === editingKey
|
||||
|
||||
const edit = (record) => {
|
||||
@ -56,7 +60,7 @@ export const EditableTable = ({
|
||||
}
|
||||
|
||||
const cancel = () => {
|
||||
if(editingKey == newRowKeyValue)
|
||||
if(editingKey === newRowKeyValue)
|
||||
{
|
||||
const newData = [...data]
|
||||
const index = newData.findIndex((item) => newRowKeyValue === item.key)
|
||||
|
Loading…
Reference in New Issue
Block a user