Repository navigation
feat(table): support nested columns and static members #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LuckyFBB
wants to merge
1
commit into
DTStack:master
Choose a base branch
from
LuckyFBB:feat_662
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,23 @@ | ||
| import React from 'react'; | ||
| import { Table } from 'dt-react-component'; | ||
|
|
||
| interface DataType { | ||
| id: number; | ||
| name: string; | ||
| age: number; | ||
| address: string; | ||
| } | ||
|
|
||
| const dataSource: DataType[] = [ | ||
| { id: 1, name: 'ZhangSan', age: 17, address: 'New York No. 1 Lake Park' }, | ||
| { id: 2, name: 'LiSi', age: 20, address: 'Bei Jing No. 1 Lake Park' }, | ||
| { id: 3, name: 'WangWu', age: 23, address: 'Zhe Jiang No. 1 Lake Park' }, | ||
| ]; | ||
|
|
||
| export default () => ( | ||
| <Table<DataType> rowKey="id" dataSource={dataSource} pagination={false}> | ||
| <Table.Column<DataType> title="Name" dataIndex="name" /> | ||
| <Table.Column<DataType> title="Age" dataIndex="age" /> | ||
| <Table.Column<DataType> title="Address" dataIndex="address" /> | ||
| </Table> | ||
| ); |
This file contains hidden or 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,37 @@ | ||
| import React from 'react'; | ||
| import { Table } from 'dt-react-component'; | ||
|
|
||
| import type { ColumnsType } from '..'; | ||
|
|
||
| interface DataType { | ||
| id: number; | ||
| name: string; | ||
| age: number; | ||
| } | ||
|
|
||
| const columns: ColumnsType<DataType> = [ | ||
| { | ||
| title: 'Name', | ||
| dataIndex: 'name', | ||
| }, | ||
| { | ||
| title: ({ sortColumns }) => { | ||
| const sortOrder = sortColumns?.find(({ column }) => column.dataIndex === 'age')?.order; | ||
| const sortText = sortOrder === 'ascend' ? 'ascending' : 'descending'; | ||
| return sortOrder ? `Age (${sortText})` : 'Age'; | ||
| }, | ||
| dataIndex: 'age', | ||
| sorter: (previous, next) => previous.age - next.age, | ||
| tooltip: 'Click the sorter to see the title update', | ||
| }, | ||
| ]; | ||
|
|
||
| const dataSource: DataType[] = [ | ||
| { id: 1, name: 'ZhangSan', age: 23 }, | ||
| { id: 2, name: 'LiSi', age: 17 }, | ||
| { id: 3, name: 'WangWu', age: 20 }, | ||
| ]; | ||
|
|
||
| export default () => ( | ||
| <Table<DataType> rowKey="id" columns={columns} dataSource={dataSource} pagination={false} /> | ||
| ); |
This file contains hidden or 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,65 @@ | ||
| import React from 'react'; | ||
| import { Table } from 'dt-react-component'; | ||
|
|
||
| import type { ColumnsType } from '..'; | ||
|
|
||
| interface DataType { | ||
| id: number; | ||
| name: string; | ||
| age: number; | ||
| city: string; | ||
| address: string; | ||
| } | ||
|
|
||
| const columns: ColumnsType<DataType> = [ | ||
| { | ||
| title: 'Basic Information', | ||
| tooltip: 'Personal information', | ||
| children: [ | ||
| { | ||
| title: 'Name', | ||
| dataIndex: 'name', | ||
| tooltip: 'User name', | ||
| }, | ||
| { | ||
| title: 'Age', | ||
| dataIndex: 'age', | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| title: 'Contact Address', | ||
| children: [ | ||
| { | ||
| title: 'City', | ||
| dataIndex: 'city', | ||
| }, | ||
| { | ||
| title: 'Address', | ||
| dataIndex: 'address', | ||
| tooltip: 'Detailed contact address', | ||
| }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
||
| const dataSource: DataType[] = [ | ||
| { | ||
| id: 1, | ||
| name: 'ZhangSan', | ||
| age: 17, | ||
| city: 'New York', | ||
| address: 'No. 1 Lake Park', | ||
| }, | ||
| { | ||
| id: 2, | ||
| name: 'LiSi', | ||
| age: 20, | ||
| city: 'Beijing', | ||
| address: 'No. 1 Lake Park', | ||
| }, | ||
| ]; | ||
|
|
||
| export default () => ( | ||
| <Table<DataType> rowKey="id" columns={columns} dataSource={dataSource} pagination={false} /> | ||
| ); |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的title是不是也会存在 (props) => React.Node 的情况