@@ -28,6 +28,7 @@ import { delay, filter, startWith, switchMap, takeUntil } from 'rxjs/operators';
28
28
import { NzResizeService } from 'ng-zorro-antd/core/services' ;
29
29
import { NzSafeAny } from 'ng-zorro-antd/core/types' ;
30
30
31
+ import { NzTableSummaryFixedType } from '../table.types' ;
31
32
import { NzTableContentComponent } from './table-content.component' ;
32
33
import { NzTbodyComponent } from './tbody.component' ;
33
34
@@ -44,6 +45,7 @@ import { NzTbodyComponent } from './tbody.component';
44
45
[scrollX]="scrollX"
45
46
[listOfColWidth]="listOfColWidth"
46
47
[theadTemplate]="theadTemplate"
48
+ [tfootTemplate]="tfootFixed === 'top' ? tfootTemplate : null"
47
49
></table>
48
50
</div>
49
51
@if (!virtualTemplate) {
@@ -76,6 +78,17 @@ import { NzTbodyComponent } from './tbody.component';
76
78
</table>
77
79
</cdk-virtual-scroll-viewport>
78
80
}
81
+ @if (tfootFixed === 'bottom') {
82
+ <div #tableFootElement class="ant-table-summary" [ngStyle]="headerStyleMap">
83
+ <table
84
+ nz-table-content
85
+ tableLayout="fixed"
86
+ [scrollX]="scrollX"
87
+ [listOfColWidth]="listOfColWidth"
88
+ [tfootTemplate]="tfootTemplate"
89
+ ></table>
90
+ </div>
91
+ }
79
92
} @else {
80
93
<div class="ant-table-content" #tableBodyElement [ngStyle]="bodyStyleMap">
81
94
<table
@@ -85,6 +98,7 @@ import { NzTbodyComponent } from './tbody.component';
85
98
[listOfColWidth]="listOfColWidth"
86
99
[theadTemplate]="theadTemplate"
87
100
[contentTemplate]="contentTemplate"
101
+ [tfootTemplate]="tfootTemplate"
88
102
></table>
89
103
</div>
90
104
}
@@ -101,6 +115,8 @@ export class NzTableInnerScrollComponent<T> implements OnChanges, AfterViewInit,
101
115
@Input ( ) widthConfig : string [ ] = [ ] ;
102
116
@Input ( ) listOfColWidth : ReadonlyArray < string | null > = [ ] ;
103
117
@Input ( ) theadTemplate : TemplateRef < NzSafeAny > | null = null ;
118
+ @Input ( ) tfootTemplate : TemplateRef < NzSafeAny > | null = null ;
119
+ @Input ( ) tfootFixed : NzTableSummaryFixedType | null = null ;
104
120
@Input ( ) virtualTemplate : TemplateRef < NzSafeAny > | null = null ;
105
121
@Input ( ) virtualItemSize = 0 ;
106
122
@Input ( ) virtualMaxBufferPx = 200 ;
@@ -109,6 +125,7 @@ export class NzTableInnerScrollComponent<T> implements OnChanges, AfterViewInit,
109
125
@Input ( ) virtualForTrackBy : TrackByFunction < T > = index => index ;
110
126
@ViewChild ( 'tableHeaderElement' , { read : ElementRef } ) tableHeaderElement ! : ElementRef ;
111
127
@ViewChild ( 'tableBodyElement' , { read : ElementRef } ) tableBodyElement ! : ElementRef ;
128
+ @ViewChild ( 'tableFootElement' , { read : ElementRef } ) tableFootElement ?: ElementRef ;
112
129
@ViewChild ( CdkVirtualScrollViewport , { read : CdkVirtualScrollViewport } )
113
130
cdkVirtualScrollViewport ?: CdkVirtualScrollViewport ;
114
131
headerStyleMap = { } ;
@@ -158,15 +175,16 @@ export class NzTableInnerScrollComponent<T> implements OnChanges, AfterViewInit,
158
175
overflowX : this . scrollX ? 'auto' : null ,
159
176
maxHeight : this . scrollY
160
177
} ;
161
- // Caretaker note: we have to emit the value outside of the Angular zone, thus DOM timer (`delay(0)`) and `scroll`
162
- // event listener will be also added outside of the Angular zone.
178
+ // Caretaker note: we have to emit the value outside the Angular zone, thus DOM timer (`delay(0)`) and `scroll`
179
+ // event listener will be also added outside the Angular zone.
163
180
this . ngZone . runOutsideAngular ( ( ) => this . scroll$ . next ( ) ) ;
164
181
}
165
182
if ( data ) {
166
183
// See the comment above.
167
184
this . ngZone . runOutsideAngular ( ( ) => this . data$ . next ( ) ) ;
168
185
}
169
186
}
187
+
170
188
ngAfterViewInit ( ) : void {
171
189
if ( this . platform . isBrowser ) {
172
190
this . ngZone . runOutsideAngular ( ( ) => {
@@ -184,14 +202,16 @@ export class NzTableInnerScrollComponent<T> implements OnChanges, AfterViewInit,
184
202
takeUntil ( this . destroy$ )
185
203
) ;
186
204
setClassName$ . subscribe ( ( ) => this . setScrollPositionClassName ( ) ) ;
187
- scrollEvent$
188
- . pipe ( filter ( ( ) => ! ! this . scrollY ) )
189
- . subscribe (
190
- ( ) => ( this . tableHeaderElement . nativeElement . scrollLeft = this . tableBodyElement . nativeElement . scrollLeft )
191
- ) ;
205
+ scrollEvent$ . pipe ( filter ( ( ) => ! ! this . scrollY ) ) . subscribe ( ( ) => {
206
+ this . tableHeaderElement . nativeElement . scrollLeft = this . tableBodyElement . nativeElement . scrollLeft ;
207
+ if ( this . tableFootElement ) {
208
+ this . tableFootElement . nativeElement . scrollLeft = this . tableBodyElement . nativeElement . scrollLeft ;
209
+ }
210
+ } ) ;
192
211
} ) ;
193
212
}
194
213
}
214
+
195
215
ngOnDestroy ( ) : void {
196
216
this . setScrollPositionClassName ( true ) ;
197
217
this . destroy$ . next ( ) ;
0 commit comments