forked from ddrilling/asb_cloud_front
Настройка столбцов временно скрыта
This commit is contained in:
parent
4bb71ddbfd
commit
6a09ab9af3
@ -15,12 +15,11 @@ export type TableColumns<T = any> = OmitExtends<BaseTableColumn<T>, ColumnSettin
|
||||
export type TableContainer = TableProps<any> & {
|
||||
columns: TableColumns
|
||||
dataSource: any[]
|
||||
children?: ReactNode
|
||||
tableName?: string
|
||||
hideSettingsChanger?: boolean
|
||||
showSettingsChanger?: boolean
|
||||
}
|
||||
|
||||
export const Table = memo<TableContainer>(({ columns, dataSource, children, tableName, hideSettingsChanger, ...other }) => {
|
||||
export const Table = memo<TableContainer>(({ columns, dataSource, tableName, showSettingsChanger, ...other }) => {
|
||||
const [newColumns, setNewColumns] = useState<TableColumns>([])
|
||||
const [settings, setSettings] = useState<TableSettings>({})
|
||||
|
||||
@ -33,7 +32,7 @@ export const Table = memo<TableContainer>(({ columns, dataSource, children, tabl
|
||||
useEffect(() => setSettings(tableName ? getTableSettings(tableName) : {}), [tableName])
|
||||
useEffect(() => setNewColumns(() => {
|
||||
const newColumns = applySettings(columns, settings)
|
||||
if (tableName && !hideSettingsChanger) {
|
||||
if (tableName && showSettingsChanger) {
|
||||
const oldTitle = newColumns[0].title
|
||||
newColumns[0].title = (props) => (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'stretch', justifyContent: 'space-between', position: 'relative', padding: '16px 0' }}>
|
||||
@ -45,14 +44,13 @@ export const Table = memo<TableContainer>(({ columns, dataSource, children, tabl
|
||||
)
|
||||
}
|
||||
return newColumns
|
||||
}), [settings, columns, onSettingsChanged, hideSettingsChanger, tableName])
|
||||
}), [settings, columns, onSettingsChanged, showSettingsChanger, tableName])
|
||||
|
||||
return (
|
||||
<RawTable
|
||||
{...other}
|
||||
columns={newColumns}
|
||||
dataSource={tryAddKeys(dataSource)}
|
||||
children={children}
|
||||
{...other}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user