@@ -11,7 +11,7 @@ interface RecordType {
1111 indexKey : string ;
1212}
1313
14- const columns : ColumnsType = [
14+ const defaultColumns : ColumnsType = [
1515 // { title: 'title1', dataIndex: 'a', key: 'a', width: 100,},
1616 // { title: 'title1', dataIndex: 'a', key: 'a', width: 100, },
1717 { title : 'title1' , dataIndex : 'a' , key : 'a' , width : 100 , fixed : 'left' } ,
@@ -183,16 +183,13 @@ const Demo = () => {
183183 const tblRef = React . useRef < Reference > ( ) ;
184184 const [ enableColRowSpan , setEnableColRowSpan ] = useState ( false ) ;
185185
186- function cleanOnCell ( cols : any = [ ] ) {
187- cols . forEach ( col => {
188- delete ( col as any ) . onCell ;
189-
190- cleanOnCell ( ( col as any ) . children ) ;
186+ function cleanOnCell ( cols : ColumnsType ) {
187+ return cols ?. map ( ( { onCell, ...col } : any ) => {
188+ return { ...col , children : cleanOnCell ( col . children ) } ;
191189 } ) ;
192190 }
193- if ( ! enableColRowSpan ) {
194- cleanOnCell ( columns ) ;
195- }
191+
192+ const columns = enableColRowSpan ? defaultColumns : cleanOnCell ( defaultColumns ) ;
196193
197194 return (
198195 < div style = { { width : 800 , padding : `0 64px` } } >
@@ -220,6 +217,7 @@ const Demo = () => {
220217 </ button >
221218
222219 < VirtualTable
220+ virtual = { { x : true } }
223221 columns = { columns }
224222 // expandedRowRender={({ b, c }) => b || c}
225223 scroll = { { x : 1300 , y : 200 } }
0 commit comments