@@ -543,8 +543,11 @@ function moveRowFromBodyToColHeader(scene: Scenegraph) {
543
543
let hasSetedHeight = false ;
544
544
// deal with bodyGroup
545
545
for ( let i = 0 ; i < scene . bodyGroup . childrenCount ; i ++ ) {
546
- const colGroup = scene . bodyGroup . children [ i ] as Group ;
547
- const rowCell = colGroup . firstChild as Group ;
546
+ const child = scene . bodyGroup . children [ i ] ;
547
+ if ( ! checkBeforeMove ( child ) ) {
548
+ continue ;
549
+ }
550
+ const rowCell = child . firstChild as Group ;
548
551
scene . colHeaderGroup . children [ i ] ?. appendChild ( rowCell ) ;
549
552
// update container width
550
553
if ( ! hasSetedHeight ) {
@@ -559,8 +562,11 @@ function moveRowFromRowHeaderToCornerHeader(scene: Scenegraph) {
559
562
let hasSetedHeight = false ;
560
563
// deal with rowHeaderGroup
561
564
for ( let i = 0 ; i < scene . rowHeaderGroup . childrenCount ; i ++ ) {
562
- const colGroup = scene . rowHeaderGroup . children [ i ] as Group ;
563
- const rowCell = colGroup . firstChild as Group ;
565
+ const child = scene . rowHeaderGroup . children [ i ] ;
566
+ if ( ! checkBeforeMove ( child ) ) {
567
+ continue ;
568
+ }
569
+ const rowCell = child . firstChild as Group ;
564
570
scene . cornerHeaderGroup . children [ i ] ?. appendChild ( rowCell ) ;
565
571
// update container width
566
572
if ( ! hasSetedHeight ) {
@@ -578,8 +584,11 @@ function moveRowFromRightToTopRightCorner(scene: Scenegraph) {
578
584
let hasSetedHeight = false ;
579
585
// deal with rowHeaderGroup
580
586
for ( let i = 0 ; i < scene . rightFrozenGroup . childrenCount ; i ++ ) {
581
- const colGroup = scene . rightFrozenGroup . children [ i ] as Group ;
582
- const rowCell = colGroup . firstChild as Group ;
587
+ const child = scene . rightFrozenGroup . children [ i ] ;
588
+ if ( ! checkBeforeMove ( child ) ) {
589
+ continue ;
590
+ }
591
+ const rowCell = child . firstChild as Group ;
583
592
scene . rightTopCornerGroup . children [ i ] ?. appendChild ( rowCell ) ;
584
593
// update container width
585
594
if ( ! hasSetedHeight ) {
@@ -597,10 +606,17 @@ function moveRowFromColHeaderToBody(scene: Scenegraph) {
597
606
let hasSetedHeight = false ;
598
607
// deal with bodyGroup
599
608
for ( let i = 0 ; i < scene . colHeaderGroup . childrenCount ; i ++ ) {
600
- const colGroup = scene . colHeaderGroup . children [ i ] as Group ;
601
- const rowCell = colGroup . lastChild as Group ;
602
- insertBefore ( scene . bodyGroup . children [ i ] as Group , rowCell , scene . bodyGroup . children [ i ] . firstChild as Group ) ;
603
- // update container width
609
+ const child = scene . colHeaderGroup . children [ i ] ;
610
+ if ( ! checkBeforeMove ( child ) ) {
611
+ continue ;
612
+ }
613
+ const target = scene . bodyGroup . children [ i ] as Group ;
614
+ if ( ! target ) {
615
+ continue ;
616
+ }
617
+ const rowCell = child . lastChild as Group ;
618
+ insertBefore ( target , rowCell , target . firstChild as Group ) ;
619
+ // 更新高度
604
620
if ( ! hasSetedHeight ) {
605
621
scene . colHeaderGroup . setAttribute ( 'height' , scene . colHeaderGroup . attribute . height - rowCell . attribute . height ) ;
606
622
scene . bodyGroup . setAttribute ( 'height' , scene . bodyGroup . attribute . height + rowCell . attribute . height ) ;
@@ -613,14 +629,17 @@ function moveRowFromCornerHeaderToRowHeader(scene: Scenegraph) {
613
629
let hasSetedHeight = false ;
614
630
// deal with rowHeaderGroup
615
631
for ( let i = 0 ; i < scene . cornerHeaderGroup . childrenCount ; i ++ ) {
616
- const colGroup = scene . cornerHeaderGroup . children [ i ] as Group ;
617
- const rowCell = colGroup . lastChild as Group ;
632
+ const child = scene . cornerHeaderGroup . children [ i ] ;
633
+ if ( ! checkBeforeMove ( child ) ) {
634
+ continue ;
635
+ }
636
+ const target = scene . rowHeaderGroup . children [ i ] as Group ;
637
+ if ( ! target ) {
638
+ continue ;
639
+ }
640
+ const rowCell = child . lastChild as Group ;
618
641
// scene.rowHeaderGroup.children[i]?.appendChild(rowCell);
619
- insertBefore (
620
- scene . rowHeaderGroup . children [ i ] as Group ,
621
- rowCell ,
622
- scene . rowHeaderGroup . children [ i ] . firstChild as Group
623
- ) ;
642
+ insertBefore ( target , rowCell , target . firstChild as Group ) ;
624
643
// update container width
625
644
if ( ! hasSetedHeight ) {
626
645
scene . cornerHeaderGroup . setAttribute (
@@ -637,14 +656,17 @@ function moveRowFromTopRightCornerToRight(scene: Scenegraph) {
637
656
let hasSetedHeight = false ;
638
657
// deal with rowHeaderGroup
639
658
for ( let i = 0 ; i < scene . rightTopCornerGroup . childrenCount ; i ++ ) {
640
- const colGroup = scene . rightTopCornerGroup . children [ i ] as Group ;
641
- const rowCell = colGroup . lastChild as Group ;
659
+ const child = scene . rightTopCornerGroup . children [ i ] ;
660
+ if ( ! checkBeforeMove ( child ) ) {
661
+ continue ;
662
+ }
663
+ const target = scene . rightFrozenGroup . children [ i ] as Group ;
664
+ if ( ! target ) {
665
+ continue ;
666
+ }
667
+ const rowCell = child . lastChild as Group ;
642
668
// scene.rightFrozenGroup.children[i]?.appendChild(rowCell);
643
- insertBefore (
644
- scene . rightFrozenGroup . children [ i ] as Group ,
645
- rowCell ,
646
- scene . rightFrozenGroup . children [ i ] . firstChild as Group
647
- ) ;
669
+ insertBefore ( target , rowCell , target . firstChild as Group ) ;
648
670
// update container width
649
671
if ( ! hasSetedHeight ) {
650
672
scene . rightTopCornerGroup . setAttribute (
@@ -656,3 +678,8 @@ function moveRowFromTopRightCornerToRight(scene: Scenegraph) {
656
678
}
657
679
}
658
680
}
681
+
682
+ function checkBeforeMove ( child : any ) {
683
+ // 跳过非 Group 类型或名为 'table-border-rect' 的边框节点
684
+ return child instanceof Group && child ?. name !== 'table-border-rect' ;
685
+ }
0 commit comments