File tree Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,23 @@ interface RecordType {
10
10
children ?: RecordType [ ] ;
11
11
}
12
12
13
+ function CustomExpandIcon ( props ) {
14
+ let text ;
15
+ if ( props . expanded ) {
16
+ text = '⇧ collapse' ;
17
+ } else {
18
+ text = '⇩ expand' ;
19
+ }
20
+ return (
21
+ < a
22
+ className = "expand-row-icon"
23
+ onClick = { e => props . onExpand ( props . record , e ) }
24
+ dangerouslySetInnerHTML = { { __html : text } }
25
+ style = { { color : 'blue' , cursor : 'pointer' } }
26
+ />
27
+ ) ;
28
+ }
29
+
13
30
const columns = [
14
31
{
15
32
title : 'Name' ,
@@ -113,6 +130,7 @@ const Demo = () => (
113
130
data = { data }
114
131
indentSize = { 30 }
115
132
onExpand = { onExpand }
133
+ expandIcon = { CustomExpandIcon }
116
134
/>
117
135
) ;
118
136
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
66
66
indentSize,
67
67
expandIcon,
68
68
expandedRowRender,
69
+ expandIconColumnIndex,
69
70
} = React . useContext ( BodyContext ) ;
70
71
const { onColumnResize } = React . useContext ( ResizeContext ) ;
71
72
const [ expandRended , setExpandRended ] = React . useState ( false ) ;
@@ -137,7 +138,7 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
137
138
138
139
// ============= Used for nest expandable =============
139
140
let appendCellNode : React . ReactNode ;
140
- if ( colIndex === 0 && nestExpandable ) {
141
+ if ( colIndex === ( expandIconColumnIndex || 0 ) && nestExpandable ) {
141
142
appendCellNode = (
142
143
< >
143
144
< span
Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ export interface TableProps<RecordType extends DefaultRecordType>
109
109
* !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
110
110
*/
111
111
// Used for antd table transform column with additional column
112
- transformColumns : ( columns : ColumnsType < RecordType > ) => ColumnsType < RecordType > ;
112
+ transformColumns ? : ( columns : ColumnsType < RecordType > ) => ColumnsType < RecordType > ;
113
113
}
114
114
115
115
function Table < RecordType extends DefaultRecordType > ( props : TableProps < RecordType > ) {
@@ -523,6 +523,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
523
523
expandRowByClick,
524
524
expandedRowRender,
525
525
onTriggerExpand,
526
+ expandIconColumnIndex,
526
527
indentSize,
527
528
} }
528
529
>
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ export interface BodyContextProps<RecordType = DefaultRecordType> {
29
29
expandedRowRender : ExpandedRowRender < RecordType > ;
30
30
expandIcon : RenderExpandIcon < RecordType > ;
31
31
onTriggerExpand : TriggerEventHandler < RecordType > ;
32
+ expandIconColumnIndex : number ;
32
33
}
33
34
34
35
const BodyContext = React . createContext < BodyContextProps > ( null ) ;
You can’t perform that action at this time.
0 commit comments