Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linweijiong
jinfa-platform
Commits
a26d6757
Commit
a26d6757
authored
Feb 19, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: columns 支持函数类型
parent
d1076053
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
3 deletions
+4
-3
index.tsx
src/components/NestTable/index.tsx
+4
-3
No files found.
src/components/NestTable/index.tsx
View file @
a26d6757
...
@@ -6,8 +6,9 @@ import { CaretRightOutlined, CaretDownOutlined } from '@ant-design/icons'
...
@@ -6,8 +6,9 @@ import { CaretRightOutlined, CaretDownOutlined } from '@ant-design/icons'
export
interface
NestTableProps
extends
TableProps
<
any
>
{
export
interface
NestTableProps
extends
TableProps
<
any
>
{
/**
/**
* 扁平化的递归嵌套类型, 后面一项永远为前一项的直系子集
* 扁平化的递归嵌套类型, 后面一项永远为前一项的直系子集
* column 可以是函数,此时可以根据业务返回不同的 column
*/
*/
NestColumns
:
ColumnsType
<
any
>
[],
NestColumns
:
(
ColumnsType
<
any
>
|
((
record
?)
=>
ColumnsType
<
any
>
))
[],
// 指定获得的子集数据类型
// 指定获得的子集数据类型
childrenDataKey
:
string
,
childrenDataKey
:
string
,
childPagination
?:
false
|
TablePaginationConfig
,
childPagination
?:
false
|
TablePaginationConfig
,
...
@@ -28,7 +29,7 @@ const NestTable: React.FC<NestTableProps> = (props) => {
...
@@ -28,7 +29,7 @@ const NestTable: React.FC<NestTableProps> = (props) => {
const
childRenderTable
=
useCallback
((
record
)
=>
{
const
childRenderTable
=
useCallback
((
record
)
=>
{
return
<
Table
return
<
Table
columns=
{
childColumns
}
columns=
{
typeof
childColumns
!==
'function'
?
childColumns
:
childColumns
(
record
)
}
size=
"middle"
size=
"middle"
dataSource=
{
record
[
childrenDataKey
]
||
[]
}
dataSource=
{
record
[
childrenDataKey
]
||
[]
}
rowClassName=
{
(
_
,
index
)
=>
(
index
%
2
)
===
0
&&
"tb_bg"
}
rowClassName=
{
(
_
,
index
)
=>
(
index
%
2
)
===
0
&&
"tb_bg"
}
...
@@ -40,7 +41,7 @@ const NestTable: React.FC<NestTableProps> = (props) => {
...
@@ -40,7 +41,7 @@ const NestTable: React.FC<NestTableProps> = (props) => {
return
(
return
(
<
Table
<
Table
columns=
{
parentColumns
}
columns=
{
parentColumns
as
ColumnsType
<
any
>
}
dataSource=
{
dataSource
}
dataSource=
{
dataSource
}
expandable=
{
{
expandable=
{
{
expandedRowRender
:
childRenderTable
,
expandedRowRender
:
childRenderTable
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment