@@ -61,6 +61,17 @@ export default {
61
61
handleVisibilityChange ( visible ) {
62
62
this . tooltipVisible = this . notShowTooltip ? false : visible ;
63
63
} ,
64
+ getRawText ( record , dataIndex ) {
65
+ let text ;
66
+ if ( typeof dataIndex === 'number' ) {
67
+ text = get ( record , dataIndex ) ;
68
+ } else if ( ! dataIndex || dataIndex . length === 0 ) {
69
+ text = record ;
70
+ } else {
71
+ text = get ( record , dataIndex ) ;
72
+ }
73
+ return text ;
74
+ } ,
64
75
} ,
65
76
66
77
render ( ) {
@@ -78,14 +89,7 @@ export default {
78
89
const cls = className || column . class ;
79
90
// We should return undefined if no dataIndex is specified, but in order to
80
91
// be compatible with object-path's behavior, we return the record object instead.
81
- let text ;
82
- if ( typeof dataIndex === 'number' ) {
83
- text = get ( record , dataIndex ) ;
84
- } else if ( ! dataIndex || dataIndex . length === 0 ) {
85
- text = record ;
86
- } else {
87
- text = get ( record , dataIndex ) ;
88
- }
92
+ let text = this . getRawText ( record , dataIndex ) ;
89
93
this . tooltipContent = text ;
90
94
91
95
let tdProps = {
@@ -133,31 +137,25 @@ export default {
133
137
tdProps . style = { ...tdProps . style , textAlign : column . align } ;
134
138
}
135
139
136
- if ( column . showOverflowTooltip ) {
137
- return (
138
- < BodyCell { ...tdProps } class = "has-tooltip" style = { { maxWidth : 0 } } >
139
- < Tooltip
140
- onVisibleChange = { this . handleVisibilityChange }
141
- visible = { this . tooltipVisible }
142
- placement = "top"
143
- title = { this . tooltipContent } >
144
- < div >
145
- { indentText }
146
- { expandIcon }
147
- { text }
148
- </ div >
149
- </ Tooltip >
150
- </ BodyCell >
151
- ) ;
152
- } else {
153
- return (
154
- < BodyCell { ...tdProps } >
155
- { indentText }
156
- { expandIcon }
157
- { text }
158
- </ BodyCell >
159
- ) ;
160
- }
140
+ const cellContent = [
141
+ indentText ,
142
+ expandIcon ,
143
+ text ,
144
+ ] ;
161
145
146
+ return column . showOverflowTooltip ? (
147
+ < BodyCell { ...tdProps } class = "has-tooltip" style = { { maxWidth : 0 } } >
148
+ < Tooltip
149
+ onVisibleChange = { this . handleVisibilityChange }
150
+ visible = { this . tooltipVisible }
151
+ title = { this . tooltipContent } >
152
+ < div > { cellContent } </ div >
153
+ </ Tooltip >
154
+ </ BodyCell >
155
+ ) : (
156
+ < BodyCell { ...tdProps } >
157
+ { cellContent }
158
+ </ BodyCell >
159
+ ) ;
162
160
} ,
163
161
} ;
0 commit comments