forked from ddrilling/asb_cloud_front
Добавлена обёртка для antd Table с автоподставлением поля key
This commit is contained in:
parent
0a0bae2b83
commit
d2d6377efd
@ -5,7 +5,7 @@ import { EditableCell } from './EditableCell'
|
||||
|
||||
const newRowKeyValue = 'newRow'
|
||||
|
||||
const tryAddKeys = (items) => {
|
||||
export const tryAddKeys = (items) => {
|
||||
if(!items?.length || !items[0])
|
||||
return []
|
||||
if(items[0].key)
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { ReactNode } from 'react'
|
||||
import { Table as RawTable } from 'antd'
|
||||
import { tryAddKeys } from './EditableTable'
|
||||
import { makeNumericSorter, makeStringSorter} from './sorters'
|
||||
export { makeDateSorter, makeNumericSorter, makeStringSorter} from './sorters'
|
||||
export { Table } from 'antd'
|
||||
export { EditableTable } from './EditableTable'
|
||||
export { DatePickerWrapper } from './DatePickerWrapper'
|
||||
export { SelectFromDictionary } from './SelectFromDictionary'
|
||||
@ -186,3 +187,12 @@ export const makePaginationObject = (paginationContainer:PaginationContainer, ..
|
||||
current: page,
|
||||
}
|
||||
}
|
||||
|
||||
interface TableContainer {
|
||||
dataSource: any[];
|
||||
children?: any;
|
||||
}
|
||||
|
||||
export const Table = ({dataSource, children, ...other}: TableContainer) => {
|
||||
return <RawTable dataSource={tryAddKeys(dataSource)} {...other}>{children}</RawTable>
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user