-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2661 from epam/feature/rc-version
[DataTable]: Added support of column groups in table header
- Loading branch information
Showing
24 changed files
with
767 additions
and
50 deletions.
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
app/src/docs/_examples/tables/TableGroupedHeader.example.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import React, { useState } from 'react'; | ||
import { DataSourceState, DataColumnProps, useUuiContext, useLazyDataSource, DataColumnGroupProps } from '@epam/uui-core'; | ||
import { Text, DataTable, Panel, FlexRow, Badge, BadgeProps } from '@epam/uui'; | ||
import { Person } from '@epam/uui-docs'; | ||
|
||
import css from './TablesExamples.module.scss'; | ||
import { TApi } from '../../../data'; | ||
|
||
export default function TableGroupedHeaderExample() { | ||
const svc = useUuiContext<TApi>(); | ||
const [tableState, setTableState] = useState<DataSourceState>({}); | ||
|
||
// Define columns groups array | ||
const columnGroups: DataColumnGroupProps[] = [ | ||
{ | ||
key: 'location', | ||
caption: 'Location', | ||
textAlign: 'center', | ||
}, | ||
{ | ||
key: 'position', | ||
caption: 'Position', | ||
textAlign: 'center', | ||
}, | ||
]; | ||
|
||
// Define columns config array | ||
const personColumns: DataColumnProps<Person, number>[] = [ | ||
{ | ||
key: 'name', | ||
caption: 'Name', | ||
render: (p) => <Text>{p.name}</Text>, | ||
width: 130, | ||
isSortable: true, | ||
}, | ||
{ | ||
key: 'profileStatus', | ||
caption: 'Status', | ||
render: (p) => ( | ||
<FlexRow> | ||
<Badge size="24" indicator fill="outline" color={ p.profileStatus.toLowerCase() as BadgeProps['color'] } caption={ p.profileStatus } /> | ||
</FlexRow> | ||
), | ||
grow: 0, | ||
width: 100, | ||
minWidth: 90, | ||
isSortable: true, | ||
}, | ||
{ | ||
key: 'countryName', | ||
caption: 'Country', | ||
group: 'location', // Specify group key | ||
render: (p) => <Text>{p.countryName}</Text>, | ||
grow: 0, | ||
width: 110, | ||
isSortable: true, | ||
}, | ||
{ | ||
key: 'cityName', | ||
caption: 'City', | ||
group: 'location', // Specify group key | ||
render: (p) => <Text>{p.cityName}</Text>, | ||
grow: 0, | ||
width: 110, | ||
isSortable: true, | ||
}, | ||
{ | ||
key: 'officeAddress', | ||
caption: 'Office', | ||
group: 'location', // Specify group key | ||
render: (p) => <Text>{p.officeAddress}</Text>, | ||
grow: 0, | ||
width: 150, | ||
isSortable: true, | ||
}, | ||
{ | ||
key: 'jobTitle', | ||
caption: 'Title', | ||
group: 'position', // Specify group key | ||
render: (r) => <Text>{r.jobTitle}</Text>, | ||
width: 180, | ||
isSortable: true, | ||
}, | ||
{ | ||
key: 'titleLevel', | ||
caption: 'Track & Level', | ||
group: 'position', // Specify group key | ||
render: (p) => <Text>{p.titleLevel}</Text>, | ||
grow: 1, | ||
width: 100, | ||
isSortable: true, | ||
}, | ||
]; | ||
|
||
const citiesDS = useLazyDataSource<Person, number, unknown>({ | ||
api: svc.api.demo.persons, | ||
backgroundReload: true, | ||
}, []); | ||
|
||
const view = citiesDS.useView(tableState, setTableState); | ||
|
||
return ( | ||
<Panel background="surface-main" shadow cx={ css.container }> | ||
<DataTable | ||
value={ tableState } | ||
onValueChange={ setTableState } | ||
{ ...view.getListProps() } | ||
getRows={ view.getVisibleRows } | ||
showColumnsConfig={ false } | ||
columnGroups={ columnGroups } | ||
columns={ personColumns } | ||
headerTextCase="upper" | ||
/> | ||
</Panel> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
public/docs/content/examples-tables-TableGroupedHeader.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[ | ||
{ | ||
"type": "paragraph", | ||
"children": [ | ||
{ | ||
"text": "To create column groups in the table header, provide the group configuration using the " | ||
}, | ||
{ | ||
"text": "columnGroups", | ||
"uui-richTextEditor-code": true | ||
}, | ||
{ | ||
"text": " prop. For each column to be grouped, specify the " | ||
}, | ||
{ | ||
"text": "group", | ||
"uui-richTextEditor-code": true | ||
}, | ||
{ | ||
"text": " field with the corresponding group key." | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "note-warning", | ||
"children": [ | ||
{ | ||
"text": "This is preview version of header groups functionality with limited support of some DataTable features, like columns reordering, resizing and columns configuration via modal." | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.