-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
Copy pathtable.ts
6026 lines (5107 loc) · 210 KB
/
table.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { animate, AnimationEvent, style, transition, trigger } from '@angular/animations';
import { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common';
import {
AfterContentInit,
AfterViewChecked,
AfterViewInit,
booleanAttribute,
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ContentChildren,
Directive,
ElementRef,
EventEmitter,
HostListener,
Inject,
Injectable,
Input,
NgModule,
NgZone,
numberAttribute,
OnChanges,
OnDestroy,
OnInit,
Optional,
Output,
PLATFORM_ID,
QueryList,
Renderer2,
SimpleChanges,
TemplateRef,
ViewChild,
ViewEncapsulation
} from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BlockableUI, FilterMatchMode, FilterMetadata, FilterOperator, FilterService, LazyLoadMeta, OverlayService, PrimeNGConfig, PrimeTemplate, ScrollerOptions, SelectItem, SharedModule, SortMeta, TableState, TranslationKeys } from 'primeng/api';
import { ButtonModule } from 'primeng/button';
import { CalendarModule } from 'primeng/calendar';
import { ConnectedOverlayScrollHandler, DomHandler } from 'primeng/dom';
import { DropdownModule } from 'primeng/dropdown';
import { ArrowDownIcon } from 'primeng/icons/arrowdown';
import { ArrowUpIcon } from 'primeng/icons/arrowup';
import { CheckIcon } from 'primeng/icons/check';
import { FilterIcon } from 'primeng/icons/filter';
import { FilterSlashIcon } from 'primeng/icons/filterslash';
import { PlusIcon } from 'primeng/icons/plus';
import { SortAltIcon } from 'primeng/icons/sortalt';
import { SortAmountDownIcon } from 'primeng/icons/sortamountdown';
import { SortAmountUpAltIcon } from 'primeng/icons/sortamountupalt';
import { SpinnerIcon } from 'primeng/icons/spinner';
import { TrashIcon } from 'primeng/icons/trash';
import { InputNumberModule } from 'primeng/inputnumber';
import { InputTextModule } from 'primeng/inputtext';
import { PaginatorModule } from 'primeng/paginator';
import { Scroller, ScrollerModule } from 'primeng/scroller';
import { SelectButtonModule } from 'primeng/selectbutton';
import { TriStateCheckboxModule } from 'primeng/tristatecheckbox';
import { Nullable, VoidListener } from 'primeng/ts-helpers';
import { ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primeng/utils';
import { Subject, Subscription } from 'rxjs';
import {
ExportCSVOptions,
TableColResizeEvent,
TableColumnReorderEvent,
TableContextMenuSelectEvent,
TableEditCancelEvent,
TableEditCompleteEvent,
TableEditInitEvent,
TableFilterEvent,
TableHeaderCheckboxToggleEvent,
TableLazyLoadEvent,
TablePageEvent,
TableRowCollapseEvent,
TableRowExpandEvent,
TableRowReorderEvent,
TableRowSelectEvent,
TableRowUnSelectEvent,
TableSelectAllChangeEvent
} from './table.interface';
@Injectable()
export class TableService {
private sortSource = new Subject<SortMeta | SortMeta[] | null>();
private selectionSource = new Subject();
private contextMenuSource = new Subject<any>();
private valueSource = new Subject<any>();
private totalRecordsSource = new Subject<any>();
private columnsSource = new Subject();
sortSource$ = this.sortSource.asObservable();
selectionSource$ = this.selectionSource.asObservable();
contextMenuSource$ = this.contextMenuSource.asObservable();
valueSource$ = this.valueSource.asObservable();
totalRecordsSource$ = this.totalRecordsSource.asObservable();
columnsSource$ = this.columnsSource.asObservable();
onSort(sortMeta: SortMeta | SortMeta[] | null) {
this.sortSource.next(sortMeta);
}
onSelectionChange() {
this.selectionSource.next(null);
}
onContextMenu(data: any) {
this.contextMenuSource.next(data);
}
onValueChange(value: any) {
this.valueSource.next(value);
}
onTotalRecordsChange(value: number) {
this.totalRecordsSource.next(value);
}
onColumnsChange(columns: any[]) {
this.columnsSource.next(columns);
}
}
/**
* Table displays data in tabular format.
* @group Components
*/
@Component({
selector: 'p-table',
template: `
<div
#container
[ngStyle]="style"
[class]="styleClass"
[ngClass]="{ 'p-datatable p-component': true, 'p-datatable-hoverable-rows': rowHover || selectionMode, 'p-datatable-scrollable': scrollable, 'p-datatable-flex-scrollable': scrollable && scrollHeight === 'flex' }"
[attr.id]="id"
>
<div class="p-datatable-loading-overlay p-component-overlay" *ngIf="loading && showLoader">
<i *ngIf="loadingIcon" [class]="'p-datatable-loading-icon ' + loadingIcon"></i>
<ng-container *ngIf="!loadingIcon">
<SpinnerIcon *ngIf="!loadingIconTemplate" [spin]="true" [styleClass]="'p-datatable-loading-icon'" />
<span *ngIf="loadingIconTemplate" class="p-datatable-loading-icon">
<ng-template *ngTemplateOutlet="loadingIconTemplate"></ng-template>
</span>
</ng-container>
</div>
<div *ngIf="captionTemplate" class="p-datatable-header">
<ng-container *ngTemplateOutlet="captionTemplate"></ng-container>
</div>
<p-paginator
[rows]="rows"
[first]="first"
[totalRecords]="totalRecords"
[pageLinkSize]="pageLinks"
[alwaysShow]="alwaysShowPaginator"
(onPageChange)="onPageChange($event)"
[rowsPerPageOptions]="rowsPerPageOptions"
*ngIf="paginator && (paginatorPosition === 'top' || paginatorPosition == 'both')"
[templateLeft]="paginatorLeftTemplate"
[templateRight]="paginatorRightTemplate"
[dropdownAppendTo]="paginatorDropdownAppendTo"
[dropdownScrollHeight]="paginatorDropdownScrollHeight"
[currentPageReportTemplate]="currentPageReportTemplate"
[showFirstLastIcon]="showFirstLastIcon"
[dropdownItemTemplate]="paginatorDropdownItemTemplate"
[showCurrentPageReport]="showCurrentPageReport"
[showJumpToPageDropdown]="showJumpToPageDropdown"
[showJumpToPageInput]="showJumpToPageInput"
[showPageLinks]="showPageLinks"
[styleClass]="getPaginatorStyleClasses('p-paginator-top')"
[locale]="paginatorLocale"
>
<ng-template pTemplate="dropdownicon" *ngIf="paginatorDropdownIconTemplate">
<ng-container *ngTemplateOutlet="paginatorDropdownIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="firstpagelinkicon" *ngIf="paginatorFirstPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorFirstPageLinkIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="previouspagelinkicon" *ngIf="paginatorPreviousPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorPreviousPageLinkIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="lastpagelinkicon" *ngIf="paginatorLastPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorLastPageLinkIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="nextpagelinkicon" *ngIf="paginatorNextPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorNextPageLinkIconTemplate"></ng-container>
</ng-template>
</p-paginator>
<div #wrapper class="p-datatable-wrapper" [ngStyle]="{ maxHeight: virtualScroll ? '' : scrollHeight }">
<p-scroller
#scroller
*ngIf="virtualScroll"
[items]="processedData"
[columns]="columns"
[style]="{ height: scrollHeight !== 'flex' ? scrollHeight : undefined }"
[scrollHeight]="scrollHeight !== 'flex' ? undefined : '100%'"
[itemSize]="virtualScrollItemSize || _virtualRowHeight"
[step]="rows"
[delay]="lazy ? virtualScrollDelay : 0"
[inline]="true"
[lazy]="lazy"
(onLazyLoad)="onLazyItemLoad($event)"
[loaderDisabled]="true"
[showSpacer]="false"
[showLoader]="loadingBodyTemplate"
[options]="virtualScrollOptions"
[autoSize]="true"
>
<ng-template pTemplate="content" let-items let-scrollerOptions="options">
<ng-container *ngTemplateOutlet="buildInTable; context: { $implicit: items, options: scrollerOptions }"></ng-container>
</ng-template>
</p-scroller>
<ng-container *ngIf="!virtualScroll">
<ng-container *ngTemplateOutlet="buildInTable; context: { $implicit: processedData, options: { columns } }"></ng-container>
</ng-container>
<ng-template #buildInTable let-items let-scrollerOptions="options">
<table
#table
role="table"
[ngClass]="{ 'p-datatable-table': true, 'p-datatable-scrollable-table': scrollable, 'p-datatable-resizable-table': resizableColumns, 'p-datatable-resizable-table-fit': resizableColumns && columnResizeMode === 'fit' }"
[class]="tableStyleClass"
[ngStyle]="tableStyle"
[attr.id]="id + '-table'"
>
<ng-container *ngTemplateOutlet="colGroupTemplate; context: { $implicit: scrollerOptions.columns }"></ng-container>
<thead role="rowgroup" #thead class="p-datatable-thead">
<ng-container *ngTemplateOutlet="headerGroupedTemplate || headerTemplate; context: { $implicit: scrollerOptions.columns }"></ng-container>
</thead>
<tbody
role="rowgroup"
class="p-datatable-tbody p-datatable-frozen-tbody"
*ngIf="frozenValue || frozenBodyTemplate"
[value]="frozenValue"
[frozenRows]="true"
[pTableBody]="scrollerOptions.columns"
[pTableBodyTemplate]="frozenBodyTemplate"
[frozen]="true"
></tbody>
<tbody
role="rowgroup"
class="p-datatable-tbody"
[ngClass]="scrollerOptions.contentStyleClass"
[ngStyle]="scrollerOptions.contentStyle"
[value]="dataToRender(scrollerOptions.rows)"
[pTableBody]="scrollerOptions.columns"
[pTableBodyTemplate]="bodyTemplate"
[scrollerOptions]="scrollerOptions"
></tbody>
<tbody
role="rowgroup"
*ngIf="scrollerOptions.spacerStyle"
[ngStyle]="{ height: 'calc(' + scrollerOptions.spacerStyle.height + ' - ' + scrollerOptions.rows.length * scrollerOptions.itemSize + 'px)' }"
class="p-datatable-scroller-spacer"
></tbody>
<tfoot role="rowgroup" *ngIf="footerGroupedTemplate || footerTemplate" #tfoot class="p-datatable-tfoot">
<ng-container *ngTemplateOutlet="footerGroupedTemplate || footerTemplate; context: { $implicit: scrollerOptions.columns }"></ng-container>
</tfoot>
</table>
</ng-template>
</div>
<p-paginator
[rows]="rows"
[first]="first"
[totalRecords]="totalRecords"
[pageLinkSize]="pageLinks"
[alwaysShow]="alwaysShowPaginator"
(onPageChange)="onPageChange($event)"
[rowsPerPageOptions]="rowsPerPageOptions"
*ngIf="paginator && (paginatorPosition === 'bottom' || paginatorPosition == 'both')"
[templateLeft]="paginatorLeftTemplate"
[templateRight]="paginatorRightTemplate"
[dropdownAppendTo]="paginatorDropdownAppendTo"
[dropdownScrollHeight]="paginatorDropdownScrollHeight"
[currentPageReportTemplate]="currentPageReportTemplate"
[showFirstLastIcon]="showFirstLastIcon"
[dropdownItemTemplate]="paginatorDropdownItemTemplate"
[showCurrentPageReport]="showCurrentPageReport"
[showJumpToPageDropdown]="showJumpToPageDropdown"
[showJumpToPageInput]="showJumpToPageInput"
[showPageLinks]="showPageLinks"
[styleClass]="getPaginatorStyleClasses('p-paginator-bottom')"
[locale]="paginatorLocale"
>
<ng-template pTemplate="dropdownicon" *ngIf="paginatorDropdownIconTemplate">
<ng-container *ngTemplateOutlet="paginatorDropdownIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="firstpagelinkicon" *ngIf="paginatorFirstPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorFirstPageLinkIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="previouspagelinkicon" *ngIf="paginatorPreviousPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorPreviousPageLinkIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="lastpagelinkicon" *ngIf="paginatorLastPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorLastPageLinkIconTemplate"></ng-container>
</ng-template>
<ng-template pTemplate="nextpagelinkicon" *ngIf="paginatorNextPageLinkIconTemplate">
<ng-container *ngTemplateOutlet="paginatorNextPageLinkIconTemplate"></ng-container>
</ng-template>
</p-paginator>
<div *ngIf="summaryTemplate" class="p-datatable-footer">
<ng-container *ngTemplateOutlet="summaryTemplate"></ng-container>
</div>
<div
#resizeHelper
class="p-column-resizer-helper"
[ngStyle]="{
display: 'none'
}"
*ngIf="resizableColumns"
></div>
<span
#reorderIndicatorUp
class="p-datatable-reorder-indicator-up"
[ngStyle]="{
display: 'none'
}"
*ngIf="reorderableColumns"
>
<ArrowDownIcon *ngIf="!reorderIndicatorUpIconTemplate" />
<ng-template *ngTemplateOutlet="reorderIndicatorUpIconTemplate"></ng-template>
</span>
<span
#reorderIndicatorDown
class="p-datatable-reorder-indicator-down"
[ngStyle]="{
display: 'none'
}"
*ngIf="reorderableColumns"
>
<ArrowUpIcon *ngIf="!reorderIndicatorDownIconTemplate" />
<ng-template *ngTemplateOutlet="reorderIndicatorDownIconTemplate"></ng-template>
</span>
</div>
`,
providers: [TableService],
changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.None,
styleUrls: ['./table.css'],
host: {
class: 'p-element'
}
})
export class Table implements OnInit, AfterViewInit, AfterContentInit, BlockableUI, OnChanges {
/**
* An array of objects to represent dynamic columns that are frozen.
* @group Props
*/
@Input() frozenColumns: any[] | undefined;
/**
* An array of objects to display as frozen.
* @group Props
*/
@Input() frozenValue: any[] | undefined;
/**
* Inline style of the component.
* @group Props
*/
@Input() style: { [klass: string]: any } | null | undefined;
/**
* Style class of the component.
* @group Props
*/
@Input() styleClass: string | undefined;
/**
* Inline style of the table.
* @group Props
*/
@Input() tableStyle: { [klass: string]: any } | null | undefined;
/**
* Style class of the table.
* @group Props
*/
@Input() tableStyleClass: string | undefined;
/**
* When specified as true, enables the pagination.
* @group Props
*/
@Input({ transform: booleanAttribute }) paginator: boolean | undefined;
/**
* Number of page links to display in paginator.
* @group Props
*/
@Input({ transform: numberAttribute }) pageLinks: number = 5;
/**
* Array of integer/object values to display inside rows per page dropdown of paginator
* @group Props
*/
@Input() rowsPerPageOptions: any[] | undefined;
/**
* Whether to show it even there is only one page.
* @group Props
*/
@Input({ transform: booleanAttribute }) alwaysShowPaginator: boolean = true;
/**
* Position of the paginator, options are "top", "bottom" or "both".
* @group Props
*/
@Input() paginatorPosition: 'top' | 'bottom' | 'both' = 'bottom';
/**
* Custom style class for paginator
* @group Props
*/
@Input() paginatorStyleClass: string | undefined;
/**
* Target element to attach the paginator dropdown overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name).
* @group Props
*/
@Input() paginatorDropdownAppendTo: HTMLElement | ElementRef | TemplateRef<any> | string | null | undefined | any;
/**
* Paginator dropdown height of the viewport in pixels, a scrollbar is defined if height of list exceeds this value.
* @group Props
*/
@Input() paginatorDropdownScrollHeight: string = '200px';
/**
* Template of the current page report element. Available placeholders are {currentPage},{totalPages},{rows},{first},{last} and {totalRecords}
* @group Props
*/
@Input() currentPageReportTemplate: string = '{currentPage} of {totalPages}';
/**
* Whether to display current page report.
* @group Props
*/
@Input({ transform: booleanAttribute }) showCurrentPageReport: boolean | undefined;
/**
* Whether to display a dropdown to navigate to any page.
* @group Props
*/
@Input({ transform: booleanAttribute }) showJumpToPageDropdown: boolean | undefined;
/**
* Whether to display a input to navigate to any page.
* @group Props
*/
@Input({ transform: booleanAttribute }) showJumpToPageInput: boolean | undefined;
/**
* When enabled, icons are displayed on paginator to go first and last page.
* @group Props
*/
@Input({ transform: booleanAttribute }) showFirstLastIcon: boolean = true;
/**
* Whether to show page links.
* @group Props
*/
@Input({ transform: booleanAttribute }) showPageLinks: boolean = true;
/**
* Sort order to use when an unsorted column gets sorted by user interaction.
* @group Props
*/
@Input({ transform: numberAttribute }) defaultSortOrder: number = 1;
/**
* Defines whether sorting works on single column or on multiple columns.
* @group Props
*/
@Input() sortMode: 'single' | 'multiple' = 'single';
/**
* When true, resets paginator to first page after sorting. Available only when sortMode is set to single.
* @group Props
*/
@Input({ transform: booleanAttribute }) resetPageOnSort: boolean = true;
/**
* Specifies the selection mode, valid values are "single" and "multiple".
* @group Props
*/
@Input() selectionMode: 'single' | 'multiple' | undefined | null;
/**
* When enabled with paginator and checkbox selection mode, the select all checkbox in the header will select all rows on the current page.
* @group Props
*/
@Input({ transform: booleanAttribute }) selectionPageOnly: boolean | undefined;
/**
* Selected row with a context menu.
* @group Props
*/
@Input() contextMenuSelection: any;
/**
* Callback to invoke on context menu selection change.
* @param {*} object - row data.
* @group Emits
*/
@Output() contextMenuSelectionChange: EventEmitter<any> = new EventEmitter();
/**
* Defines the behavior of context menu selection, in "separate" mode context menu updates contextMenuSelection property whereas in joint mode selection property is used instead so that when row selection is enabled, both row selection and context menu selection use the same property.
* @group Props
*/
@Input() contextMenuSelectionMode: string = 'separate';
/**
* A property to uniquely identify a record in data.
* @group Props
*/
@Input() dataKey: string | undefined;
/**
* Defines whether metaKey should be considered for the selection. On touch enabled devices, metaKeySelection is turned off automatically.
* @group Props
*/
@Input({ transform: booleanAttribute }) metaKeySelection: boolean | undefined = false;
/**
* Defines if the row is selectable.
* @group Props
*/
@Input() rowSelectable: (row: { data: any; index: number }) => boolean | undefined;
/**
* Function to optimize the dom operations by delegating to ngForTrackBy, default algorithm checks for object identity.
* @group Props
*/
@Input() rowTrackBy: Function = (index: number, item: any) => item;
/**
* Defines if data is loaded and interacted with in lazy manner.
* @group Props
*/
@Input({ transform: booleanAttribute }) lazy: boolean = false;
/**
* Whether to call lazy loading on initialization.
* @group Props
*/
@Input({ transform: booleanAttribute }) lazyLoadOnInit: boolean = true;
/**
* Algorithm to define if a row is selected, valid values are "equals" that compares by reference and "deepEquals" that compares all fields.
* @group Props
*/
@Input() compareSelectionBy: 'equals' | 'deepEquals' = 'deepEquals';
/**
* Character to use as the csv separator.
* @group Props
*/
@Input() csvSeparator: string = ',';
/**
* Name of the exported file.
* @group Props
*/
@Input() exportFilename: string = 'download';
/**
* An array of FilterMetadata objects to provide external filters.
* @group Props
*/
@Input() filters: { [s: string]: FilterMetadata | FilterMetadata[] } = {};
/**
* An array of fields as string to use in global filtering.
* @group Props
*/
@Input() globalFilterFields: string[] | undefined;
/**
* Delay in milliseconds before filtering the data.
* @group Props
*/
@Input({ transform: numberAttribute }) filterDelay: number = 300;
/**
* Locale to use in filtering. The default locale is the host environment's current locale.
* @group Props
*/
@Input() filterLocale: string | undefined;
/**
* Map instance to keep the expanded rows where key of the map is the data key of the row.
* @group Props
*/
@Input() expandedRowKeys: { [s: string]: boolean } = {};
/**
* Map instance to keep the rows being edited where key of the map is the data key of the row.
* @group Props
*/
@Input() editingRowKeys: { [s: string]: boolean } = {};
/**
* Whether multiple rows can be expanded at any time. Valid values are "multiple" and "single".
* @group Props
*/
@Input() rowExpandMode: 'multiple' | 'single' = 'multiple';
/**
* Enables scrollable tables.
* @group Props
*/
@Input({ transform: booleanAttribute }) scrollable: boolean | undefined;
/**
* Orientation of the scrolling, options are "vertical", "horizontal" and "both".
* @group Props
* @deprecated Property is obselete since v14.2.0.
*/
@Input() scrollDirection: 'vertical' | 'horizontal' | 'both' = 'vertical';
/**
* Type of the row grouping, valid values are "subheader" and "rowspan".
* @group Props
*/
@Input() rowGroupMode: 'subheader' | 'rowspan' | undefined;
/**
* Height of the scroll viewport in fixed pixels or the "flex" keyword for a dynamic size.
* @group Props
*/
@Input() scrollHeight: string | undefined;
/**
* Whether the data should be loaded on demand during scroll.
* @group Props
*/
@Input({ transform: booleanAttribute }) virtualScroll: boolean | undefined;
/**
* Height of a row to use in calculations of virtual scrolling.
* @group Props
*/
@Input({ transform: numberAttribute }) virtualScrollItemSize: number | undefined;
/**
* Whether to use the scroller feature. The properties of scroller component can be used like an object in it.
* @group Props
*/
@Input() virtualScrollOptions: ScrollerOptions | undefined;
/**
* Threshold in milliseconds to delay lazy loading during scrolling.
* @group Props
*/
@Input({ transform: numberAttribute }) virtualScrollDelay: number = 250;
/**
* Width of the frozen columns container.
* @group Props
*/
@Input() frozenWidth: string | undefined;
/**
* Defines if the table is responsive.
* @group Props
* @deprecated table is always responsive with scrollable behavior.
*/
@Input() get responsive(): boolean | undefined | null {
return this._responsive;
}
set responsive(val: boolean | undefined | null) {
this._responsive = val;
console.warn('responsive property is deprecated as table is always responsive with scrollable behavior.');
}
_responsive: boolean | undefined | null;
/**
* Local ng-template varilable of a ContextMenu.
* @group Props
*/
@Input() contextMenu: any;
/**
* When enabled, columns can be resized using drag and drop.
* @group Props
*/
@Input({ transform: booleanAttribute }) resizableColumns: boolean | undefined;
/**
* Defines whether the overall table width should change on column resize, valid values are "fit" and "expand".
* @group Props
*/
@Input() columnResizeMode: string = 'fit';
/**
* When enabled, columns can be reordered using drag and drop.
* @group Props
*/
@Input({ transform: booleanAttribute }) reorderableColumns: boolean | undefined;
/**
* Displays a loader to indicate data load is in progress.
* @group Props
*/
@Input({ transform: booleanAttribute }) loading: boolean | undefined;
/**
* The icon to show while indicating data load is in progress.
* @group Props
*/
@Input() loadingIcon: string | undefined;
/**
* Whether to show the loading mask when loading property is true.
* @group Props
*/
@Input({ transform: booleanAttribute }) showLoader: boolean = true;
/**
* Adds hover effect to rows without the need for selectionMode. Note that tr elements that can be hovered need to have "p-selectable-row" class for rowHover to work.
* @group Props
*/
@Input({ transform: booleanAttribute }) rowHover: boolean | undefined;
/**
* Whether to use the default sorting or a custom one using sortFunction.
* @group Props
*/
@Input({ transform: booleanAttribute }) customSort: boolean | undefined;
/**
* Whether to use the initial sort badge or not.
* @group Props
*/
@Input({ transform: booleanAttribute }) showInitialSortBadge: boolean = true;
/**
* Whether the cell widths scale according to their content or not. Deprecated: Table layout is always "auto".
* @group Props
*/
@Input({ transform: booleanAttribute }) autoLayout: boolean | undefined;
/**
* Export function.
* @group Props
*/
@Input() exportFunction: Function | undefined;
/**
* Custom export header of the column to be exported as CSV.
* @group Props
*/
@Input() exportHeader: string | undefined;
/**
* Unique identifier of a stateful table to use in state storage.
* @group Props
*/
@Input() stateKey: string | undefined;
/**
* Defines where a stateful table keeps its state, valid values are "session" for sessionStorage and "local" for localStorage.
* @group Props
*/
@Input() stateStorage: 'session' | 'local' = 'session';
/**
* Defines the editing mode, valid values are "cell" and "row".
* @group Props
*/
@Input() editMode: 'cell' | 'row' = 'cell';
/**
* Field name to use in row grouping.
* @group Props
*/
@Input() groupRowsBy: any;
/**
* Order to sort when default row grouping is enabled.
* @group Props
*/
@Input({ transform: numberAttribute }) groupRowsByOrder: number = 1;
/**
* Defines the responsive mode, valid options are "stack" and "scroll".
* @group Props
*/
@Input() responsiveLayout: string = 'scroll';
/**
* The breakpoint to define the maximum width boundary when using stack responsive layout.
* @group Props
*/
@Input() breakpoint: string = '960px';
/**
* Locale to be used in paginator formatting.
* @group Props
*/
@Input() paginatorLocale: string | undefined;
/**
* An array of objects to display.
* @group Props
*/
@Input() get value(): any[] {
return this._value;
}
set value(val: any[]) {
this._value = val;
}
/**
* An array of objects to represent dynamic columns.
* @group Props
*/
@Input() get columns(): any[] | undefined {
return this._columns;
}
set columns(cols: any[] | undefined) {
this._columns = cols;
}
/**
* Index of the first row to be displayed.
* @group Props
*/
@Input() get first(): number | null | undefined {
return this._first;
}
set first(val: number | null | undefined) {
this._first = val;
}
/**
* Number of rows to display per page.
* @group Props
*/
@Input() get rows(): number | undefined {
return this._rows;
}
set rows(val: number | undefined) {
this._rows = val;
}
/**
* Number of total records, defaults to length of value when not defined.
* @group Props
*/
@Input() get totalRecords(): number {
return this._totalRecords;
}
set totalRecords(val: number) {
this._totalRecords = val;
this.tableService.onTotalRecordsChange(this._totalRecords);
}
/**
* Name of the field to sort data by default.
* @group Props
*/
@Input() get sortField(): string | undefined | null {
return this._sortField;
}
set sortField(val: string | undefined | null) {
this._sortField = val;
}
/**
* Order to sort when default sorting is enabled.
* @group Props
*/
@Input() get sortOrder(): number {
return this._sortOrder;
}
set sortOrder(val: number) {
this._sortOrder = val;
}
/**
* An array of SortMeta objects to sort the data by default in multiple sort mode.
* @group Props
*/
@Input() get multiSortMeta(): SortMeta[] | undefined | null {
return this._multiSortMeta;
}
set multiSortMeta(val: SortMeta[] | undefined | null) {
this._multiSortMeta = val;
}
/**
* Selected row in single mode or an array of values in multiple mode.
* @group Props
*/
@Input() get selection(): any {
return this._selection;
}
set selection(val: any) {
this._selection = val;
}
/**
* Whether all data is selected.
* @group Props
*/
@Input() get selectAll(): boolean | null {
return this._selection;
}
set selectAll(val: boolean | null) {
this._selection = val;
}
/**
* Emits when the all of the items selected or unselected.
* @param {TableSelectAllChangeEvent} event - custom all selection change event.
* @group Emits
*/
@Output() selectAllChange: EventEmitter<TableSelectAllChangeEvent> = new EventEmitter<TableSelectAllChangeEvent>();
/**
* Callback to invoke on selection changed.
* @param {any | null} value - selected data.
* @group Emits
*/
@Output() selectionChange: EventEmitter<any | null> = new EventEmitter<any | null>();
/**
* Callback to invoke when a row is selected.
* @param {TableRowSelectEvent} event - custom select event.
* @group Emits
*/
@Output() onRowSelect: EventEmitter<TableRowSelectEvent> = new EventEmitter<TableRowSelectEvent>();
/**
* Callback to invoke when a row is unselected.
* @param {TableRowUnSelectEvent} event - custom unselect event.
* @group Emits
*/
@Output() onRowUnselect: EventEmitter<TableRowUnSelectEvent> = new EventEmitter<TableRowUnSelectEvent>();
/**
* Callback to invoke when pagination occurs.
* @param {TablePageEvent} event - custom pagination event.
* @group Emits
*/
@Output() onPage: EventEmitter<TablePageEvent> = new EventEmitter<TablePageEvent>();
/**
* Callback to invoke when a column gets sorted.
* @param {Object} object - sort meta.
* @group Emits
*/
@Output() onSort: EventEmitter<{ multisortmeta: SortMeta[] } | any> = new EventEmitter<{ multisortmeta: SortMeta[] } | any>();
/**
* Callback to invoke when data is filtered.
* @param {TableFilterEvent} event - custom filtering event.
* @group Emits
*/
@Output() onFilter: EventEmitter<TableFilterEvent> = new EventEmitter<TableFilterEvent>();
/**
* Callback to invoke when paging, sorting or filtering happens in lazy mode.
* @param {TableLazyLoadEvent} event - custom lazy loading event.
* @group Emits
*/
@Output() onLazyLoad: EventEmitter<TableLazyLoadEvent> = new EventEmitter<TableLazyLoadEvent>();
/**
* Callback to invoke when a row is expanded.
* @param {TableRowExpandEvent} event - custom row expand event.
* @group Emits
*/
@Output() onRowExpand: EventEmitter<TableRowExpandEvent> = new EventEmitter<TableRowExpandEvent>();
/**
* Callback to invoke when a row is collapsed.
* @param {TableRowCollapseEvent} event - custom row collapse event.
* @group Emits
*/
@Output() onRowCollapse: EventEmitter<TableRowCollapseEvent> = new EventEmitter<TableRowCollapseEvent>();
/**
* Callback to invoke when a row is selected with right click.
* @param {TableContextMenuSelectEvent} event - custom context menu select event.
* @group Emits
*/
@Output() onContextMenuSelect: EventEmitter<TableContextMenuSelectEvent> = new EventEmitter<TableContextMenuSelectEvent>();
/**
* Callback to invoke when a column is resized.
* @param {TableColResizeEvent} event - custom column resize event.
* @group Emits
*/
@Output() onColResize: EventEmitter<TableColResizeEvent> = new EventEmitter<TableColResizeEvent>();
/**
* Callback to invoke when a column is reordered.
* @param {TableColumnReorderEvent} event - custom column reorder event.
* @group Emits
*/
@Output() onColReorder: EventEmitter<TableColumnReorderEvent> = new EventEmitter<TableColumnReorderEvent>();
/**
* Callback to invoke when a row is reordered.
* @param {TableRowReorderEvent} event - custom row reorder event.
* @group Emits
*/
@Output() onRowReorder: EventEmitter<TableRowReorderEvent> = new EventEmitter<TableRowReorderEvent>();
/**
* Callback to invoke when a cell switches to edit mode.
* @param {TableEditInitEvent} event - custom edit init event.
* @group Emits
*/
@Output() onEditInit: EventEmitter<TableEditInitEvent> = new EventEmitter<TableEditInitEvent>();
/**
* Callback to invoke when cell edit is completed.
* @param {TableEditCompleteEvent} event - custom edit complete event.
* @group Emits
*/
@Output() onEditComplete: EventEmitter<TableEditCompleteEvent> = new EventEmitter<TableEditCompleteEvent>();
/**
* Callback to invoke when cell edit is cancelled with escape key.
* @param {TableEditCancelEvent} event - custom edit cancel event.
* @group Emits
*/
@Output() onEditCancel: EventEmitter<TableEditCancelEvent> = new EventEmitter<TableEditCancelEvent>();
/**
* Callback to invoke when state of header checkbox changes.
* @param {TableHeaderCheckboxToggleEvent} event - custom header checkbox event.
* @group Emits
*/
@Output() onHeaderCheckboxToggle: EventEmitter<TableHeaderCheckboxToggleEvent> = new EventEmitter<TableHeaderCheckboxToggleEvent>();
/**
* A function to implement custom sorting, refer to sorting section for details.
* @param {any} any - sort meta.
* @group Emits
*/
@Output() sortFunction: EventEmitter<any> = new EventEmitter<any>();
/**
* Callback to invoke on pagination.
* @param {number} number - first element.
* @group Emits
*/
@Output() firstChange: EventEmitter<number> = new EventEmitter<number>();
/**
* Callback to invoke on rows change.
* @param {number} number - Row count.
* @group Emits
*/
@Output() rowsChange: EventEmitter<number> = new EventEmitter<number>();
/**
* Callback to invoke table state is saved.
* @param {TableState} object - table state.
* @group Emits
*/
@Output() onStateSave: EventEmitter<TableState> = new EventEmitter<TableState>();
/**
* Callback to invoke table state is restored.
* @param {TableState} object - table state.
* @group Emits
*/
@Output() onStateRestore: EventEmitter<TableState> = new EventEmitter<TableState>();
@ViewChild('container') containerViewChild: Nullable<ElementRef>;
@ViewChild('resizeHelper') resizeHelperViewChild: Nullable<ElementRef>;
@ViewChild('reorderIndicatorUp') reorderIndicatorUpViewChild: Nullable<ElementRef>;
@ViewChild('reorderIndicatorDown') reorderIndicatorDownViewChild: Nullable<ElementRef>;
@ViewChild('wrapper') wrapperViewChild: Nullable<ElementRef>;
@ViewChild('table') tableViewChild: Nullable<ElementRef>;
@ViewChild('thead') tableHeaderViewChild: Nullable<ElementRef>;
@ViewChild('tfoot') tableFooterViewChild: Nullable<ElementRef>;
@ViewChild('scroller') scroller: Nullable<Scroller>;
@ContentChildren(PrimeTemplate) templates: Nullable<QueryList<PrimeTemplate>>;
/**
* Indicates the height of rows to be scrolled.
* @group Props