@swimlane/ngx-datatable 13.1.0 → 15.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/config/webpack.package.js +2 -15
- package/package.json +19 -20
- package/release/components/body/body-cell.component.d.ts +1 -1
- package/release/components/body/body-cell.component.js +7 -6
- package/release/components/body/body-cell.component.js.map +1 -1
- package/release/components/body/body-cell.component.metadata.json +1 -1
- package/release/components/body/body-group-header.directive.d.ts +1 -1
- package/release/components/body/body-group-header.directive.js +4 -1
- package/release/components/body/body-group-header.directive.js.map +1 -1
- package/release/components/body/body-group-header.directive.metadata.json +1 -1
- package/release/components/body/body-row-wrapper.component.js.map +1 -1
- package/release/components/body/body-row.component.d.ts +1 -3
- package/release/components/body/body-row.component.js +3 -3
- package/release/components/body/body-row.component.js.map +1 -1
- package/release/components/body/body.component.js +13 -13
- package/release/components/body/body.component.js.map +1 -1
- package/release/components/body/body.component.metadata.json +1 -1
- package/release/components/body/scroller.component.js.map +1 -1
- package/release/components/body/selection.component.js +1 -1
- package/release/components/body/selection.component.js.map +1 -1
- package/release/components/body/summary/summary-row.component.d.ts +3 -3
- package/release/components/body/summary/summary-row.component.js +10 -7
- package/release/components/body/summary/summary-row.component.js.map +1 -1
- package/release/components/columns/column.directive.js +12 -3
- package/release/components/columns/column.directive.js.map +1 -1
- package/release/components/columns/column.directive.metadata.json +1 -1
- package/release/components/datatable.component.d.ts +22 -22
- package/release/components/datatable.component.js +16 -13
- package/release/components/datatable.component.js.map +1 -1
- package/release/components/datatable.component.metadata.json +1 -1
- package/release/components/footer/footer.component.js.map +1 -1
- package/release/components/footer/footer.directive.js +4 -1
- package/release/components/footer/footer.directive.js.map +1 -1
- package/release/components/footer/footer.directive.metadata.json +1 -1
- package/release/components/footer/pager.component.js.map +1 -1
- package/release/components/header/header-cell.component.d.ts +1 -1
- package/release/components/header/header-cell.component.js.map +1 -1
- package/release/components/header/header.component.d.ts +6 -8
- package/release/components/header/header.component.js +13 -10
- package/release/components/header/header.component.js.map +1 -1
- package/release/components/row-detail/row-detail.directive.d.ts +1 -1
- package/release/components/row-detail/row-detail.directive.js +4 -1
- package/release/components/row-detail/row-detail.directive.js.map +1 -1
- package/release/components/row-detail/row-detail.directive.metadata.json +1 -1
- package/release/directives/draggable.directive.d.ts +1 -1
- package/release/directives/draggable.directive.js.map +1 -1
- package/release/directives/long-press.directive.d.ts +1 -1
- package/release/directives/long-press.directive.js.map +1 -1
- package/release/directives/orderable.directive.d.ts +3 -3
- package/release/directives/orderable.directive.js +2 -2
- package/release/directives/orderable.directive.js.map +1 -1
- package/release/directives/orderable.directive.metadata.json +1 -1
- package/release/directives/resizeable.directive.d.ts +1 -1
- package/release/directives/resizeable.directive.js.map +1 -1
- package/release/directives/visibility.directive.js.map +1 -1
- package/release/index.css +2 -2
- package/release/index.js +102 -81
- package/release/index.min.js +1 -1
- package/release/index.min.js.map +1 -1
- package/release/services/column-changes.service.js.map +1 -1
- package/release/services/dimensions-helper.service.js.map +1 -1
- package/release/services/scrollbar-helper.service.js +2 -2
- package/release/services/scrollbar-helper.service.js.map +1 -1
- package/release/services/scrollbar-helper.service.metadata.json +1 -1
- package/release/types/click.type.d.ts +1 -1
- package/release/types/column-mode.type.d.ts +1 -1
- package/release/types/contextmenu.type.d.ts +1 -1
- package/release/types/selection.type.d.ts +1 -1
- package/release/types/sort-direction.type.d.ts +1 -1
- package/release/types/sort.type.d.ts +1 -1
- package/release/utils/camel-case.js.map +1 -1
- package/release/utils/column-helper.js.map +1 -1
- package/release/utils/column-prop-getters.js.map +1 -1
- package/release/utils/column.js.map +1 -1
- package/release/utils/elm-from-point.js.map +1 -1
- package/release/utils/id.js.map +1 -1
- package/release/utils/keys.d.ts +1 -1
- package/release/utils/math.js.map +1 -1
- package/release/utils/prefixes.js.map +1 -1
- package/release/utils/row-height-cache.d.ts +1 -1
- package/release/utils/row-height-cache.js.map +1 -1
- package/release/utils/selection.js.map +1 -1
- package/release/utils/sort.js.map +1 -1
- package/release/utils/throttle.d.ts +1 -1
- package/release/utils/throttle.js.map +1 -1
- package/release/utils/translate.js.map +1 -1
- package/release/utils/tree.d.ts +1 -1
- package/release/utils/tree.js +4 -4
- package/release/utils/tree.js.map +1 -1
- package/src/components/body/body-cell.component.ts +74 -38
- package/src/components/body/body-group-header.directive.ts +13 -5
- package/src/components/body/body-row.component.ts +4 -4
- package/src/components/body/body.component.ts +68 -40
- package/src/components/columns/column.directive.ts +25 -12
- package/src/components/datatable.component.ts +5 -5
- package/src/components/footer/footer.component.spec.ts +13 -11
- package/src/components/footer/footer.directive.ts +12 -4
- package/src/components/header/header.component.ts +4 -4
- package/src/components/row-detail/row-detail.directive.ts +14 -6
- package/src/directives/orderable.directive.ts +1 -1
- package/src/services/scrollbar-helper.service.ts +2 -4
- package/src/utils/column-helper.ts +25 -22
- package/src/utils/tree.ts +2 -2
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Input,
|
|
3
|
+
Output,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
Directive,
|
|
6
|
+
TemplateRef,
|
|
7
|
+
ContentChild
|
|
8
|
+
} from '@angular/core';
|
|
2
9
|
import { DatatableGroupHeaderTemplateDirective } from './body-group-header-template.directive';
|
|
3
10
|
|
|
4
11
|
@Directive({ selector: 'ngx-datatable-group-header' })
|
|
5
12
|
export class DatatableGroupHeaderDirective {
|
|
6
|
-
|
|
7
13
|
/**
|
|
8
14
|
* Row height is required when virtual scroll is enabled.
|
|
9
15
|
*/
|
|
10
|
-
@Input() rowHeight:
|
|
16
|
+
@Input() rowHeight: number | ((group?: any, index?: number) => number) = 0;
|
|
11
17
|
|
|
12
18
|
@Input()
|
|
13
|
-
@ContentChild(DatatableGroupHeaderTemplateDirective, {
|
|
19
|
+
@ContentChild(DatatableGroupHeaderTemplateDirective, {
|
|
20
|
+
read: TemplateRef,
|
|
21
|
+
static: true
|
|
22
|
+
})
|
|
14
23
|
template: TemplateRef<any>;
|
|
15
24
|
|
|
16
25
|
/**
|
|
@@ -47,5 +56,4 @@ export class DatatableGroupHeaderDirective {
|
|
|
47
56
|
value: false
|
|
48
57
|
});
|
|
49
58
|
}
|
|
50
|
-
|
|
51
59
|
}
|
|
@@ -118,7 +118,7 @@ export class DataTableBodyRowComponent implements DoCheck {
|
|
|
118
118
|
_offsetX: number;
|
|
119
119
|
_columns: any[];
|
|
120
120
|
_innerWidth: number;
|
|
121
|
-
_groupStyles = {
|
|
121
|
+
_groupStyles: {[prop: string]: {}} = {
|
|
122
122
|
left: {},
|
|
123
123
|
center: {},
|
|
124
124
|
right: {}
|
|
@@ -150,9 +150,9 @@ export class DataTableBodyRowComponent implements DoCheck {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
buildStylesByGroup() {
|
|
153
|
-
this._groupStyles
|
|
154
|
-
this._groupStyles
|
|
155
|
-
this._groupStyles
|
|
153
|
+
this._groupStyles.left = this.calcStylesByGroup('left');
|
|
154
|
+
this._groupStyles.center = this.calcStylesByGroup('center');
|
|
155
|
+
this._groupStyles.right = this.calcStylesByGroup('right');
|
|
156
156
|
this.cd.markForCheck();
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Component,
|
|
3
|
-
|
|
2
|
+
Component,
|
|
3
|
+
Output,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
Input,
|
|
6
|
+
HostBinding,
|
|
7
|
+
ChangeDetectorRef,
|
|
8
|
+
ViewChild,
|
|
9
|
+
OnInit,
|
|
10
|
+
OnDestroy,
|
|
11
|
+
ChangeDetectionStrategy
|
|
4
12
|
} from '@angular/core';
|
|
5
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
translateXY,
|
|
15
|
+
columnsByPin,
|
|
16
|
+
columnGroupWidths,
|
|
17
|
+
RowHeightCache
|
|
18
|
+
} from '../../utils';
|
|
6
19
|
import { SelectionType } from '../../types';
|
|
7
20
|
import { ScrollerComponent } from './scroller.component';
|
|
8
21
|
import { MouseEvent } from '../../events';
|
|
@@ -19,38 +32,40 @@ import { MouseEvent } from '../../events';
|
|
|
19
32
|
[selectionType]="selectionType"
|
|
20
33
|
[rowIdentity]="rowIdentity"
|
|
21
34
|
(select)="select.emit($event)"
|
|
22
|
-
(activate)="activate.emit($event)"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</datatable-progress>
|
|
35
|
+
(activate)="activate.emit($event)"
|
|
36
|
+
>
|
|
37
|
+
<datatable-progress *ngIf="loadingIndicator"> </datatable-progress>
|
|
26
38
|
<datatable-scroller
|
|
27
39
|
*ngIf="rows?.length"
|
|
28
40
|
[scrollbarV]="scrollbarV"
|
|
29
41
|
[scrollbarH]="scrollbarH"
|
|
30
42
|
[scrollHeight]="scrollHeight"
|
|
31
43
|
[scrollWidth]="columnGroupWidths?.total"
|
|
32
|
-
(scroll)="onBodyScroll($event)"
|
|
44
|
+
(scroll)="onBodyScroll($event)"
|
|
45
|
+
>
|
|
33
46
|
<datatable-summary-row
|
|
34
47
|
*ngIf="summaryRow && summaryPosition === 'top'"
|
|
35
48
|
[rowHeight]="summaryHeight"
|
|
36
49
|
[offsetX]="offsetX"
|
|
37
50
|
[innerWidth]="innerWidth"
|
|
38
51
|
[rows]="rows"
|
|
39
|
-
[columns]="columns"
|
|
52
|
+
[columns]="columns"
|
|
53
|
+
>
|
|
40
54
|
</datatable-summary-row>
|
|
41
55
|
<datatable-row-wrapper
|
|
42
56
|
[groupedRows]="groupedRows"
|
|
43
|
-
*ngFor="let group of temp; let i = index; trackBy: rowTrackingFn
|
|
57
|
+
*ngFor="let group of temp; let i = index; trackBy: rowTrackingFn"
|
|
44
58
|
[innerWidth]="innerWidth"
|
|
45
59
|
[ngStyle]="getRowsStyles(group)"
|
|
46
60
|
[rowDetail]="rowDetail"
|
|
47
61
|
[groupHeader]="groupHeader"
|
|
48
62
|
[offsetX]="offsetX"
|
|
49
|
-
[detailRowHeight]="getDetailRowHeight(group[i],i)"
|
|
63
|
+
[detailRowHeight]="getDetailRowHeight(group[i], i)"
|
|
50
64
|
[row]="group"
|
|
51
65
|
[expanded]="getRowExpanded(group)"
|
|
52
66
|
[rowIndex]="getRowIndex(group[i])"
|
|
53
|
-
(rowContextmenu)="rowContextmenu.emit($event)"
|
|
67
|
+
(rowContextmenu)="rowContextmenu.emit($event)"
|
|
68
|
+
>
|
|
54
69
|
<datatable-body-row
|
|
55
70
|
*ngIf="!groupedRows; else groupedRowsTemplate"
|
|
56
71
|
tabindex="-1"
|
|
@@ -66,11 +81,16 @@ import { MouseEvent } from '../../events';
|
|
|
66
81
|
[displayCheck]="displayCheck"
|
|
67
82
|
[treeStatus]="group.treeStatus"
|
|
68
83
|
(treeAction)="onTreeAction(group)"
|
|
69
|
-
(activate)="selector.onActivate($event, indexes.first + i)"
|
|
84
|
+
(activate)="selector.onActivate($event, indexes.first + i)"
|
|
85
|
+
>
|
|
70
86
|
</datatable-body-row>
|
|
71
87
|
<ng-template #groupedRowsTemplate>
|
|
72
88
|
<datatable-body-row
|
|
73
|
-
*ngFor="
|
|
89
|
+
*ngFor="
|
|
90
|
+
let row of group.value;
|
|
91
|
+
let i = index;
|
|
92
|
+
trackBy: rowTrackingFn
|
|
93
|
+
"
|
|
74
94
|
tabindex="-1"
|
|
75
95
|
[isSelected]="selector.getRowSelected(row)"
|
|
76
96
|
[innerWidth]="innerWidth"
|
|
@@ -82,7 +102,8 @@ import { MouseEvent } from '../../events';
|
|
|
82
102
|
[rowIndex]="getRowIndex(row)"
|
|
83
103
|
[expanded]="getRowExpanded(row)"
|
|
84
104
|
[rowClass]="rowClass"
|
|
85
|
-
(activate)="selector.onActivate($event, i)"
|
|
105
|
+
(activate)="selector.onActivate($event, i)"
|
|
106
|
+
>
|
|
86
107
|
</datatable-body-row>
|
|
87
108
|
</ng-template>
|
|
88
109
|
</datatable-row-wrapper>
|
|
@@ -93,14 +114,15 @@ import { MouseEvent } from '../../events';
|
|
|
93
114
|
[offsetX]="offsetX"
|
|
94
115
|
[innerWidth]="innerWidth"
|
|
95
116
|
[rows]="rows"
|
|
96
|
-
[columns]="columns"
|
|
117
|
+
[columns]="columns"
|
|
118
|
+
>
|
|
97
119
|
</datatable-summary-row>
|
|
98
120
|
</datatable-scroller>
|
|
99
121
|
<div
|
|
100
122
|
class="empty-row"
|
|
101
123
|
*ngIf="!rows?.length && !loadingIndicator"
|
|
102
|
-
[innerHTML]="emptyMessage"
|
|
103
|
-
|
|
124
|
+
[innerHTML]="emptyMessage"
|
|
125
|
+
></div>
|
|
104
126
|
</datatable-selection>
|
|
105
127
|
`,
|
|
106
128
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
@@ -109,7 +131,6 @@ import { MouseEvent } from '../../events';
|
|
|
109
131
|
}
|
|
110
132
|
})
|
|
111
133
|
export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
112
|
-
|
|
113
134
|
@Input() scrollbarV: boolean;
|
|
114
135
|
@Input() scrollbarH: boolean;
|
|
115
136
|
@Input() loadingIndicator: boolean;
|
|
@@ -212,10 +233,12 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
212
233
|
@Output() activate: EventEmitter<any> = new EventEmitter();
|
|
213
234
|
@Output() select: EventEmitter<any> = new EventEmitter();
|
|
214
235
|
@Output() detailToggle: EventEmitter<any> = new EventEmitter();
|
|
215
|
-
@Output() rowContextmenu = new EventEmitter<{ event: MouseEvent
|
|
236
|
+
@Output() rowContextmenu = new EventEmitter<{ event: MouseEvent; row: any }>(
|
|
237
|
+
false
|
|
238
|
+
);
|
|
216
239
|
@Output() treeAction: EventEmitter<any> = new EventEmitter();
|
|
217
240
|
|
|
218
|
-
@ViewChild(ScrollerComponent) scroller: ScrollerComponent;
|
|
241
|
+
@ViewChild(ScrollerComponent, { static: false }) scroller: ScrollerComponent;
|
|
219
242
|
|
|
220
243
|
/**
|
|
221
244
|
* Returns if selection is enabled.
|
|
@@ -260,15 +283,14 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
260
283
|
*/
|
|
261
284
|
constructor(private cd: ChangeDetectorRef) {
|
|
262
285
|
// declare fn here so we can get access to the `this` property
|
|
263
|
-
this.rowTrackingFn =
|
|
286
|
+
this.rowTrackingFn = (index: number, row: any): any => {
|
|
264
287
|
const idx = this.getRowIndex(row);
|
|
265
288
|
if (this.trackByProp) {
|
|
266
|
-
return
|
|
289
|
+
return row[this.trackByProp];
|
|
267
290
|
} else {
|
|
268
291
|
return idx;
|
|
269
292
|
}
|
|
270
|
-
}
|
|
271
|
-
|
|
293
|
+
};
|
|
272
294
|
}
|
|
273
295
|
|
|
274
296
|
/**
|
|
@@ -276,8 +298,8 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
276
298
|
*/
|
|
277
299
|
ngOnInit(): void {
|
|
278
300
|
if (this.rowDetail) {
|
|
279
|
-
this.listener = this.rowDetail.toggle
|
|
280
|
-
|
|
301
|
+
this.listener = this.rowDetail.toggle.subscribe(
|
|
302
|
+
({ type, value }: { type: string; value: any }) => {
|
|
281
303
|
if (type === 'row') this.toggleRowExpansion(value);
|
|
282
304
|
if (type === 'all') this.toggleAllRows(value);
|
|
283
305
|
|
|
@@ -286,12 +308,13 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
286
308
|
this.updateIndexes();
|
|
287
309
|
this.updateRows();
|
|
288
310
|
this.cd.markForCheck();
|
|
289
|
-
}
|
|
311
|
+
}
|
|
312
|
+
);
|
|
290
313
|
}
|
|
291
314
|
|
|
292
315
|
if (this.groupHeader) {
|
|
293
|
-
this.listener = this.groupHeader.toggle
|
|
294
|
-
|
|
316
|
+
this.listener = this.groupHeader.toggle.subscribe(
|
|
317
|
+
({ type, value }: { type: string; value: any }) => {
|
|
295
318
|
if (type === 'group') this.toggleRowExpansion(value);
|
|
296
319
|
if (type === 'all') this.toggleAllRows(value);
|
|
297
320
|
|
|
@@ -300,7 +323,8 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
300
323
|
this.updateIndexes();
|
|
301
324
|
this.updateRows();
|
|
302
325
|
this.cd.markForCheck();
|
|
303
|
-
}
|
|
326
|
+
}
|
|
327
|
+
);
|
|
304
328
|
}
|
|
305
329
|
}
|
|
306
330
|
|
|
@@ -386,7 +410,7 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
386
410
|
// if grouprowsby has been specified treat row paging
|
|
387
411
|
// parameters as group paging parameters ie if limit 10 has been
|
|
388
412
|
// specified treat it as 10 groups rather than 10 rows
|
|
389
|
-
if(this.groupedRows) {
|
|
413
|
+
if (this.groupedRows) {
|
|
390
414
|
let maxRowsPerGroup = 3;
|
|
391
415
|
// if there is only one group set the maximum number of
|
|
392
416
|
// rows per group the same as the total number of rows
|
|
@@ -547,7 +571,7 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
547
571
|
* Hides the loading indicator
|
|
548
572
|
*/
|
|
549
573
|
hideIndicator(): void {
|
|
550
|
-
setTimeout(() => this.loadingIndicator = false, 500);
|
|
574
|
+
setTimeout(() => (this.loadingIndicator = false), 500);
|
|
551
575
|
}
|
|
552
576
|
|
|
553
577
|
/**
|
|
@@ -577,7 +601,7 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
577
601
|
if (!this.externalPaging) {
|
|
578
602
|
first = Math.max(this.offset * this.pageSize, 0);
|
|
579
603
|
}
|
|
580
|
-
last = Math.min(
|
|
604
|
+
last = Math.min(first + this.pageSize, this.rowCount);
|
|
581
605
|
}
|
|
582
606
|
|
|
583
607
|
this.indexes = { first, last };
|
|
@@ -619,8 +643,12 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
619
643
|
const viewPortFirstRowIndex = this.indexes.first;
|
|
620
644
|
|
|
621
645
|
if (this.scrollbarV && this.virtualization) {
|
|
622
|
-
const offsetScroll = this.rowHeightsCache.query(
|
|
623
|
-
|
|
646
|
+
const offsetScroll = this.rowHeightsCache.query(
|
|
647
|
+
viewPortFirstRowIndex - 1
|
|
648
|
+
);
|
|
649
|
+
return offsetScroll <= this.offsetY
|
|
650
|
+
? viewPortFirstRowIndex - 1
|
|
651
|
+
: viewPortFirstRowIndex;
|
|
624
652
|
}
|
|
625
653
|
|
|
626
654
|
return viewPortFirstRowIndex;
|
|
@@ -639,7 +667,8 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
639
667
|
|
|
640
668
|
// If the detailRowHeight is auto --> only in case of non-virtualized scroll
|
|
641
669
|
if (this.scrollbarV && this.virtualization) {
|
|
642
|
-
const detailRowHeight =
|
|
670
|
+
const detailRowHeight =
|
|
671
|
+
this.getDetailRowHeight(row) * (expanded ? -1 : 1);
|
|
643
672
|
// const idx = this.rowIndexes.get(row) || 0;
|
|
644
673
|
const idx = this.getRowIndex(row);
|
|
645
674
|
this.rowHeightsCache.update(idx, detailRowHeight);
|
|
@@ -710,9 +739,9 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
710
739
|
width: `${widths[group]}px`
|
|
711
740
|
};
|
|
712
741
|
|
|
713
|
-
if(group === 'left') {
|
|
742
|
+
if (group === 'left') {
|
|
714
743
|
translateXY(styles, offsetX, 0);
|
|
715
|
-
} else if(group === 'right') {
|
|
744
|
+
} else if (group === 'right') {
|
|
716
745
|
const bodyWidth = parseInt(this.innerWidth + '', 0);
|
|
717
746
|
const totalDiff = widths.total - bodyWidth;
|
|
718
747
|
const offsetDiff = totalDiff - offsetX;
|
|
@@ -747,5 +776,4 @@ export class DataTableBodyComponent implements OnInit, OnDestroy {
|
|
|
747
776
|
onTreeAction(row: any) {
|
|
748
777
|
this.treeAction.emit({ row });
|
|
749
778
|
}
|
|
750
|
-
|
|
751
779
|
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Directive,
|
|
3
|
+
TemplateRef,
|
|
4
|
+
ContentChild,
|
|
5
|
+
Input,
|
|
6
|
+
OnChanges,
|
|
7
|
+
SimpleChanges
|
|
8
|
+
} from '@angular/core';
|
|
2
9
|
import { DataTableColumnHeaderDirective } from './column-header.directive';
|
|
3
10
|
import { DataTableColumnCellDirective } from './column-cell.directive';
|
|
4
|
-
import {
|
|
5
|
-
DataTableColumnCellTreeToggle
|
|
6
|
-
} from './tree.directive';
|
|
11
|
+
import { DataTableColumnCellTreeToggle } from './tree.directive';
|
|
7
12
|
import { TableColumnProp } from '../../types';
|
|
8
13
|
import { ColumnChangesService } from '../../services/column-changes.service';
|
|
9
14
|
|
|
10
15
|
@Directive({ selector: 'ngx-datatable-column' })
|
|
11
16
|
export class DataTableColumnDirective implements OnChanges {
|
|
12
|
-
|
|
13
17
|
@Input() name: string;
|
|
14
18
|
@Input() prop: TableColumnProp;
|
|
15
19
|
@Input() frozenLeft: any;
|
|
@@ -26,28 +30,37 @@ export class DataTableColumnDirective implements OnChanges {
|
|
|
26
30
|
@Input() maxWidth: number;
|
|
27
31
|
@Input() checkboxable: boolean;
|
|
28
32
|
@Input() headerCheckboxable: boolean;
|
|
29
|
-
@Input() headerClass: string | ((data: any) => string|any);
|
|
30
|
-
@Input() cellClass: string | ((data: any) => string|any);
|
|
33
|
+
@Input() headerClass: string | ((data: any) => string | any);
|
|
34
|
+
@Input() cellClass: string | ((data: any) => string | any);
|
|
31
35
|
@Input() isTreeColumn: boolean;
|
|
32
36
|
@Input() treeLevelIndent: number;
|
|
33
37
|
@Input() summaryFunc: (cells: any[]) => any;
|
|
34
38
|
@Input() summaryTemplate: TemplateRef<any>;
|
|
35
39
|
|
|
36
40
|
@Input()
|
|
37
|
-
@ContentChild(DataTableColumnCellDirective, {
|
|
41
|
+
@ContentChild(DataTableColumnCellDirective, {
|
|
42
|
+
read: TemplateRef,
|
|
43
|
+
static: true
|
|
44
|
+
})
|
|
38
45
|
cellTemplate: TemplateRef<any>;
|
|
39
46
|
|
|
40
47
|
@Input()
|
|
41
|
-
@ContentChild(DataTableColumnHeaderDirective, {
|
|
48
|
+
@ContentChild(DataTableColumnHeaderDirective, {
|
|
49
|
+
read: TemplateRef,
|
|
50
|
+
static: true
|
|
51
|
+
})
|
|
42
52
|
headerTemplate: TemplateRef<any>;
|
|
43
53
|
|
|
44
54
|
@Input()
|
|
45
|
-
@ContentChild(DataTableColumnCellTreeToggle, {
|
|
55
|
+
@ContentChild(DataTableColumnCellTreeToggle, {
|
|
56
|
+
read: TemplateRef,
|
|
57
|
+
static: true
|
|
58
|
+
})
|
|
46
59
|
treeToggleTemplate: TemplateRef<any>;
|
|
47
60
|
private isFirstChange = true;
|
|
48
|
-
|
|
61
|
+
|
|
49
62
|
constructor(private columnChangesService: ColumnChangesService) {}
|
|
50
|
-
|
|
63
|
+
|
|
51
64
|
ngOnChanges() {
|
|
52
65
|
if (this.isFirstChange) {
|
|
53
66
|
this.isFirstChange = false;
|
|
@@ -640,26 +640,26 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit {
|
|
|
640
640
|
/**
|
|
641
641
|
* Row Detail templates gathered from the ContentChild
|
|
642
642
|
*/
|
|
643
|
-
@ContentChild(DatatableRowDetailDirective)
|
|
643
|
+
@ContentChild(DatatableRowDetailDirective, { static: false })
|
|
644
644
|
rowDetail: DatatableRowDetailDirective;
|
|
645
645
|
|
|
646
646
|
/**
|
|
647
647
|
* Group Header templates gathered from the ContentChild
|
|
648
648
|
*/
|
|
649
|
-
@ContentChild(DatatableGroupHeaderDirective)
|
|
649
|
+
@ContentChild(DatatableGroupHeaderDirective, { static: false })
|
|
650
650
|
groupHeader: DatatableGroupHeaderDirective;
|
|
651
651
|
|
|
652
652
|
/**
|
|
653
653
|
* Footer template gathered from the ContentChild
|
|
654
654
|
*/
|
|
655
|
-
@ContentChild(DatatableFooterDirective)
|
|
655
|
+
@ContentChild(DatatableFooterDirective, { static: false })
|
|
656
656
|
footer: DatatableFooterDirective;
|
|
657
657
|
|
|
658
658
|
/**
|
|
659
659
|
* Reference to the body component for manually
|
|
660
660
|
* invoking functions on the body.
|
|
661
661
|
*/
|
|
662
|
-
@ViewChild(DataTableBodyComponent)
|
|
662
|
+
@ViewChild(DataTableBodyComponent, { static: false })
|
|
663
663
|
bodyComponent: DataTableBodyComponent;
|
|
664
664
|
|
|
665
665
|
/**
|
|
@@ -670,7 +670,7 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit {
|
|
|
670
670
|
* @type {DataTableHeaderComponent}
|
|
671
671
|
* @memberOf DatatableComponent
|
|
672
672
|
*/
|
|
673
|
-
@ViewChild(DataTableHeaderComponent)
|
|
673
|
+
@ViewChild(DataTableHeaderComponent, { static: false })
|
|
674
674
|
headerComponent: DataTableHeaderComponent;
|
|
675
675
|
|
|
676
676
|
/**
|
|
@@ -249,23 +249,25 @@ describe('DataTableFooterComponent', () => {
|
|
|
249
249
|
[selectedCount]="selectedCount"
|
|
250
250
|
[selectedMessage]="selectedMessage"
|
|
251
251
|
[pagerNextIcon]="pagerNextIcon"
|
|
252
|
-
(page)="onPageEvent($event)"
|
|
252
|
+
(page)="onPageEvent($event)"
|
|
253
|
+
>
|
|
253
254
|
</datatable-footer>
|
|
254
|
-
|
|
255
|
+
|
|
255
256
|
<ng-template
|
|
256
257
|
#testTemplate
|
|
257
258
|
let-rowCount="rowCount"
|
|
258
259
|
let-pageSize="pageSize"
|
|
259
260
|
let-selectedCount="selectedCount"
|
|
260
261
|
let-curPage="curPage"
|
|
261
|
-
let-offset="offset"
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
</
|
|
262
|
+
let-offset="offset"
|
|
263
|
+
>
|
|
264
|
+
<ul id="template-list">
|
|
265
|
+
<li>rowCount {{ rowCount }}</li>
|
|
266
|
+
<li>pageSize {{ pageSize }}</li>
|
|
267
|
+
<li>selectedCount {{ selectedCount }}</li>
|
|
268
|
+
<li>curPage {{ curPage }}</li>
|
|
269
|
+
<li>offset {{ offset }}</li>
|
|
270
|
+
</ul>
|
|
269
271
|
</ng-template>
|
|
270
272
|
`
|
|
271
273
|
})
|
|
@@ -288,7 +290,7 @@ class TestFixtureComponent {
|
|
|
288
290
|
* selectively be passed to the DatatableFooterComponent
|
|
289
291
|
* in these unit tests
|
|
290
292
|
*/
|
|
291
|
-
@ViewChild('testTemplate', { read: TemplateRef })
|
|
293
|
+
@ViewChild('testTemplate', { read: TemplateRef, static: true })
|
|
292
294
|
testTemplate: TemplateRef<any>;
|
|
293
295
|
|
|
294
296
|
onPageEvent() {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Input,
|
|
3
|
+
Output,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
Directive,
|
|
6
|
+
TemplateRef,
|
|
7
|
+
ContentChild
|
|
8
|
+
} from '@angular/core';
|
|
2
9
|
import { DataTableFooterTemplateDirective } from './footer-template.directive';
|
|
3
10
|
|
|
4
11
|
@Directive({ selector: 'ngx-datatable-footer' })
|
|
5
12
|
export class DatatableFooterDirective {
|
|
6
|
-
|
|
7
13
|
@Input() footerHeight: number;
|
|
8
14
|
@Input() totalMessage: string;
|
|
9
15
|
@Input() selectedMessage: string | boolean;
|
|
@@ -13,7 +19,9 @@ export class DatatableFooterDirective {
|
|
|
13
19
|
@Input() pagerNextIcon: string;
|
|
14
20
|
|
|
15
21
|
@Input()
|
|
16
|
-
@ContentChild(DataTableFooterTemplateDirective, {
|
|
22
|
+
@ContentChild(DataTableFooterTemplateDirective, {
|
|
23
|
+
read: TemplateRef,
|
|
24
|
+
static: false
|
|
25
|
+
})
|
|
17
26
|
template: TemplateRef<any>;
|
|
18
|
-
|
|
19
27
|
}
|
|
@@ -134,7 +134,7 @@ export class DataTableHeaderComponent {
|
|
|
134
134
|
_offsetX: number;
|
|
135
135
|
_columns: any[];
|
|
136
136
|
_headerHeight: string;
|
|
137
|
-
_styleByGroup = {
|
|
137
|
+
_styleByGroup: {[prop: string]: {}} = {
|
|
138
138
|
left: {},
|
|
139
139
|
center: {},
|
|
140
140
|
right: {}
|
|
@@ -277,9 +277,9 @@ export class DataTableHeaderComponent {
|
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
setStylesByGroup() {
|
|
280
|
-
this._styleByGroup
|
|
281
|
-
this._styleByGroup
|
|
282
|
-
this._styleByGroup
|
|
280
|
+
this._styleByGroup.left = this.calcStylesByGroup('left');
|
|
281
|
+
this._styleByGroup.center = this.calcStylesByGroup('center');
|
|
282
|
+
this._styleByGroup.right = this.calcStylesByGroup('right');
|
|
283
283
|
this.cd.detectChanges();
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Input,
|
|
3
|
+
Output,
|
|
4
|
+
EventEmitter,
|
|
5
|
+
Directive,
|
|
6
|
+
TemplateRef,
|
|
7
|
+
ContentChild
|
|
8
|
+
} from '@angular/core';
|
|
2
9
|
import { DatatableRowDetailTemplateDirective } from './row-detail-template.directive';
|
|
3
10
|
|
|
4
11
|
@Directive({ selector: 'ngx-datatable-row-detail' })
|
|
5
12
|
export class DatatableRowDetailDirective {
|
|
6
|
-
|
|
7
13
|
/**
|
|
8
|
-
* The detail row height is required especially
|
|
14
|
+
* The detail row height is required especially
|
|
9
15
|
* when virtual scroll is enabled.
|
|
10
16
|
*/
|
|
11
|
-
@Input() rowHeight:
|
|
17
|
+
@Input() rowHeight: number | ((row?: any, index?: number) => number) = 0;
|
|
12
18
|
|
|
13
19
|
@Input()
|
|
14
|
-
@ContentChild(DatatableRowDetailTemplateDirective, {
|
|
20
|
+
@ContentChild(DatatableRowDetailTemplateDirective, {
|
|
21
|
+
read: TemplateRef,
|
|
22
|
+
static: true
|
|
23
|
+
})
|
|
15
24
|
template: TemplateRef<any>;
|
|
16
25
|
|
|
17
26
|
/**
|
|
@@ -48,5 +57,4 @@ export class DatatableRowDetailDirective {
|
|
|
48
57
|
value: false
|
|
49
58
|
});
|
|
50
59
|
}
|
|
51
|
-
|
|
52
60
|
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
QueryList, KeyValueDiffers, AfterContentInit, OnDestroy, Inject
|
|
4
4
|
} from '@angular/core';
|
|
5
5
|
import { DraggableDirective } from './draggable.directive';
|
|
6
|
-
import { DOCUMENT } from '@angular/
|
|
6
|
+
import { DOCUMENT } from '@angular/common';
|
|
7
7
|
|
|
8
8
|
@Directive({ selector: '[orderable]' })
|
|
9
9
|
export class OrderableDirective implements AfterContentInit, OnDestroy {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Inject, Injectable } from '@angular/core';
|
|
2
|
-
import { DOCUMENT } from '@angular/
|
|
2
|
+
import { DOCUMENT } from '@angular/common';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Gets the width of the scrollbar. Nesc for windows
|
|
@@ -7,10 +7,9 @@ import { DOCUMENT } from '@angular/platform-browser';
|
|
|
7
7
|
*/
|
|
8
8
|
@Injectable()
|
|
9
9
|
export class ScrollbarHelper {
|
|
10
|
-
|
|
11
10
|
width: number = this.getWidth();
|
|
12
11
|
|
|
13
|
-
constructor(@Inject(DOCUMENT) private document: any) {
|
|
12
|
+
constructor(@Inject(DOCUMENT) private document: any) {}
|
|
14
13
|
|
|
15
14
|
getWidth(): number {
|
|
16
15
|
const outer = this.document.createElement('div');
|
|
@@ -31,5 +30,4 @@ export class ScrollbarHelper {
|
|
|
31
30
|
|
|
32
31
|
return widthNoScroll - widthWithScroll;
|
|
33
32
|
}
|
|
34
|
-
|
|
35
33
|
}
|