UNPKG

16.5 kBTypeScriptView Raw
1import { ElementRef, EventEmitter, OnInit, QueryList, AfterViewInit, DoCheck, KeyValueDiffers, KeyValueDiffer, ChangeDetectorRef } from '@angular/core';
2import { DatatableGroupHeaderDirective } from './body/body-group-header.directive';
3import { BehaviorSubject, Subscription } from 'rxjs';
4import { INgxDatatableConfig } from '../ngx-datatable.module';
5import { TableColumn } from '../types/table-column.type';
6import { ColumnMode } from '../types/column-mode.type';
7import { SelectionType } from '../types/selection.type';
8import { SortType } from '../types/sort.type';
9import { ContextmenuType } from '../types/contextmenu.type';
10import { DataTableColumnDirective } from './columns/column.directive';
11import { DatatableRowDetailDirective } from './row-detail/row-detail.directive';
12import { DatatableFooterDirective } from './footer/footer.directive';
13import { DataTableBodyComponent } from './body/body.component';
14import { DataTableHeaderComponent } from './header/header.component';
15import { ScrollbarHelper } from '../services/scrollbar-helper.service';
16import { ColumnChangesService } from '../services/column-changes.service';
17import { DimensionsHelper } from '../services/dimensions-helper.service';
18import * as i0 from "@angular/core";
19export declare class DatatableComponent implements OnInit, DoCheck, AfterViewInit {
20 private scrollbarHelper;
21 private dimensionsHelper;
22 private cd;
23 private columnChangesService;
24 private configuration;
25 /**
26 * Template for the target marker of drag target columns.
27 */
28 targetMarkerTemplate: any;
29 /**
30 * Rows that are displayed in the table.
31 */
32 set rows(val: any);
33 /**
34 * Gets the rows.
35 */
36 get rows(): any;
37 /**
38 * This attribute allows the user to set the name of the column to group the data with
39 */
40 set groupRowsBy(val: string);
41 get groupRowsBy(): string;
42 /**
43 * This attribute allows the user to set a grouped array in the following format:
44 * [
45 * {groupid=1} [
46 * {id=1 name="test1"},
47 * {id=2 name="test2"},
48 * {id=3 name="test3"}
49 * ]},
50 * {groupid=2>[
51 * {id=4 name="test4"},
52 * {id=5 name="test5"},
53 * {id=6 name="test6"}
54 * ]}
55 * ]
56 */
57 groupedRows: any[];
58 /**
59 * Columns to be displayed.
60 */
61 set columns(val: TableColumn[]);
62 /**
63 * Get the columns.
64 */
65 get columns(): TableColumn[];
66 /**
67 * List of row objects that should be
68 * represented as selected in the grid.
69 * Default value: `[]`
70 */
71 selected: any[];
72 /**
73 * Enable vertical scrollbars
74 */
75 scrollbarV: boolean;
76 /**
77 * Enable horz scrollbars
78 */
79 scrollbarH: boolean;
80 /**
81 * The row height; which is necessary
82 * to calculate the height for the lazy rendering.
83 */
84 rowHeight: number | 'auto' | ((row?: any) => number);
85 /**
86 * Type of column width distribution formula.
87 * Example: flex, force, standard
88 */
89 columnMode: ColumnMode | keyof typeof ColumnMode;
90 /**
91 * The minimum header height in pixels.
92 * Pass a falsey for no header
93 */
94 headerHeight: number;
95 /**
96 * The minimum footer height in pixels.
97 * Pass falsey for no footer
98 */
99 footerHeight: number;
100 /**
101 * If the table should use external paging
102 * otherwise its assumed that all data is preloaded.
103 */
104 externalPaging: boolean;
105 /**
106 * If the table should use external sorting or
107 * the built-in basic sorting.
108 */
109 externalSorting: boolean;
110 /**
111 * The page size to be shown.
112 * Default value: `undefined`
113 */
114 set limit(val: number | undefined);
115 /**
116 * Gets the limit.
117 */
118 get limit(): number | undefined;
119 /**
120 * The total count of all rows.
121 * Default value: `0`
122 */
123 set count(val: number);
124 /**
125 * Gets the count.
126 */
127 get count(): number;
128 /**
129 * The current offset ( page - 1 ) shown.
130 * Default value: `0`
131 */
132 set offset(val: number);
133 get offset(): number;
134 /**
135 * Show the linear loading bar.
136 * Default value: `false`
137 */
138 loadingIndicator: boolean;
139 /**
140 * Type of row selection. Options are:
141 *
142 * - `single`
143 * - `multi`
144 * - `checkbox`
145 * - `multiClick`
146 * - `cell`
147 *
148 * For no selection pass a `falsey`.
149 * Default value: `undefined`
150 */
151 selectionType: SelectionType;
152 /**
153 * Enable/Disable ability to re-order columns
154 * by dragging them.
155 */
156 reorderable: boolean;
157 /**
158 * Swap columns on re-order columns or
159 * move them.
160 */
161 swapColumns: boolean;
162 /**
163 * The type of sorting
164 */
165 sortType: SortType;
166 /**
167 * Array of sorted columns by property and type.
168 * Default value: `[]`
169 */
170 sorts: any[];
171 /**
172 * Css class overrides
173 */
174 cssClasses: any;
175 /**
176 * Message overrides for localization
177 *
178 * emptyMessage [default] = 'No data to display'
179 * totalMessage [default] = 'total'
180 * selectedMessage [default] = 'selected'
181 */
182 messages: any;
183 /**
184 * Row specific classes.
185 * Similar implementation to ngClass.
186 *
187 * [rowClass]="'first second'"
188 * [rowClass]="{ 'first': true, 'second': true, 'third': false }"
189 */
190 rowClass: any;
191 /**
192 * A boolean/function you can use to check whether you want
193 * to select a particular row based on a criteria. Example:
194 *
195 * (selection) => {
196 * return selection !== 'Ethel Price';
197 * }
198 */
199 selectCheck: any;
200 /**
201 * A function you can use to check whether you want
202 * to show the checkbox for a particular row based on a criteria. Example:
203 *
204 * (row, column, value) => {
205 * return row.name !== 'Ethel Price';
206 * }
207 */
208 displayCheck: (row: any, column?: any, value?: any) => boolean;
209 /**
210 * A boolean you can use to set the detault behaviour of rows and groups
211 * whether they will start expanded or not. If ommited the default is NOT expanded.
212 *
213 */
214 groupExpansionDefault: boolean;
215 /**
216 * Property to which you can use for custom tracking of rows.
217 * Example: 'name'
218 */
219 trackByProp: string;
220 /**
221 * Property to which you can use for determining select all
222 * rows on current page or not.
223 *
224 * @memberOf DatatableComponent
225 */
226 selectAllRowsOnPage: boolean;
227 /**
228 * A flag for row virtualization on / off
229 */
230 virtualization: boolean;
231 /**
232 * Tree from relation
233 */
234 treeFromRelation: string;
235 /**
236 * Tree to relation
237 */
238 treeToRelation: string;
239 /**
240 * A flag for switching summary row on / off
241 */
242 summaryRow: boolean;
243 /**
244 * A height of summary row
245 */
246 summaryHeight: number;
247 /**
248 * A property holds a summary row position: top/bottom
249 */
250 summaryPosition: string;
251 /**
252 * Body was scrolled typically in a `scrollbarV:true` scenario.
253 */
254 scroll: EventEmitter<any>;
255 /**
256 * A cell or row was focused via keyboard or mouse click.
257 */
258 activate: EventEmitter<any>;
259 /**
260 * A cell or row was selected.
261 */
262 select: EventEmitter<any>;
263 /**
264 * Column sort was invoked.
265 */
266 sort: EventEmitter<any>;
267 /**
268 * The table was paged either triggered by the pager or the body scroll.
269 */
270 page: EventEmitter<any>;
271 /**
272 * Columns were re-ordered.
273 */
274 reorder: EventEmitter<any>;
275 /**
276 * Column was resized.
277 */
278 resize: EventEmitter<any>;
279 /**
280 * The context menu was invoked on the table.
281 * type indicates whether the header or the body was clicked.
282 * content contains either the column or the row that was clicked.
283 */
284 tableContextmenu: EventEmitter<{
285 event: MouseEvent;
286 type: ContextmenuType;
287 content: any;
288 }>;
289 /**
290 * A row was expanded ot collapsed for tree
291 */
292 treeAction: EventEmitter<any>;
293 /**
294 * CSS class applied if the header height if fixed height.
295 */
296 get isFixedHeader(): boolean;
297 /**
298 * CSS class applied to the root element if
299 * the row heights are fixed heights.
300 */
301 get isFixedRow(): boolean;
302 /**
303 * CSS class applied to root element if
304 * vertical scrolling is enabled.
305 */
306 get isVertScroll(): boolean;
307 /**
308 * CSS class applied to root element if
309 * virtualization is enabled.
310 */
311 get isVirtualized(): boolean;
312 /**
313 * CSS class applied to the root element
314 * if the horziontal scrolling is enabled.
315 */
316 get isHorScroll(): boolean;
317 /**
318 * CSS class applied to root element is selectable.
319 */
320 get isSelectable(): boolean;
321 /**
322 * CSS class applied to root is checkbox selection.
323 */
324 get isCheckboxSelection(): boolean;
325 /**
326 * CSS class applied to root if cell selection.
327 */
328 get isCellSelection(): boolean;
329 /**
330 * CSS class applied to root if single select.
331 */
332 get isSingleSelection(): boolean;
333 /**
334 * CSS class added to root element if mulit select
335 */
336 get isMultiSelection(): boolean;
337 /**
338 * CSS class added to root element if mulit click select
339 */
340 get isMultiClickSelection(): boolean;
341 /**
342 * Column templates gathered from `ContentChildren`
343 * if described in your markup.
344 */
345 set columnTemplates(val: QueryList<DataTableColumnDirective>);
346 /**
347 * Returns the column templates.
348 */
349 get columnTemplates(): QueryList<DataTableColumnDirective>;
350 /**
351 * Row Detail templates gathered from the ContentChild
352 */
353 rowDetail: DatatableRowDetailDirective;
354 /**
355 * Group Header templates gathered from the ContentChild
356 */
357 groupHeader: DatatableGroupHeaderDirective;
358 /**
359 * Footer template gathered from the ContentChild
360 */
361 footer: DatatableFooterDirective;
362 /**
363 * Reference to the body component for manually
364 * invoking functions on the body.
365 */
366 bodyComponent: DataTableBodyComponent;
367 /**
368 * Reference to the header component for manually
369 * invoking functions on the header.
370 *
371 * @memberOf DatatableComponent
372 */
373 headerComponent: DataTableHeaderComponent;
374 /**
375 * Returns if all rows are selected.
376 */
377 get allRowsSelected(): boolean;
378 element: HTMLElement;
379 _innerWidth: number;
380 pageSize: number;
381 bodyHeight: number;
382 rowCount: number;
383 rowDiffer: KeyValueDiffer<{}, {}>;
384 _offsetX: BehaviorSubject<number>;
385 _limit: number | undefined;
386 _count: number;
387 _offset: number;
388 _rows: any[];
389 _groupRowsBy: string;
390 _internalRows: any[];
391 _internalColumns: TableColumn[];
392 _columns: TableColumn[];
393 _columnTemplates: QueryList<DataTableColumnDirective>;
394 _subscriptions: Subscription[];
395 constructor(scrollbarHelper: ScrollbarHelper, dimensionsHelper: DimensionsHelper, cd: ChangeDetectorRef, element: ElementRef, differs: KeyValueDiffers, columnChangesService: ColumnChangesService, configuration: INgxDatatableConfig);
396 /**
397 * Lifecycle hook that is called after data-bound
398 * properties of a directive are initialized.
399 */
400 ngOnInit(): void;
401 /**
402 * Lifecycle hook that is called after a component's
403 * view has been fully initialized.
404 */
405 ngAfterViewInit(): void;
406 /**
407 * Lifecycle hook that is called after a component's
408 * content has been fully initialized.
409 */
410 ngAfterContentInit(): void;
411 /**
412 * This will be used when displaying or selecting rows.
413 * when tracking/comparing them, we'll use the value of this fn,
414 *
415 * (`fn(x) === fn(y)` instead of `x === y`)
416 */
417 rowIdentity: (x: any) => any;
418 /**
419 * Translates the templates to the column objects
420 */
421 translateColumns(val: any): void;
422 /**
423 * Creates a map with the data grouped by the user choice of grouping index
424 *
425 * @param originalArray the original array passed via parameter
426 * @param groupByIndex the index of the column to group the data by
427 */
428 groupArrayBy(originalArray: any, groupBy: any): {
429 key: any;
430 value: any;
431 }[];
432 ngDoCheck(): void;
433 /**
434 * Recalc's the sizes of the grid.
435 *
436 * Updated automatically on changes to:
437 *
438 * - Columns
439 * - Rows
440 * - Paging related
441 *
442 * Also can be manually invoked or upon window resize.
443 */
444 recalculate(): void;
445 /**
446 * Window resize handler to update sizes.
447 */
448 onWindowResize(): void;
449 /**
450 * Recalulcates the column widths based on column width
451 * distribution mode and scrollbar offsets.
452 */
453 recalculateColumns(columns?: any[], forceIdx?: number, allowBleed?: boolean): any[] | undefined;
454 /**
455 * Recalculates the dimensions of the table size.
456 * Internally calls the page size and row count calcs too.
457 *
458 */
459 recalculateDims(): void;
460 /**
461 * Recalculates the pages after a update.
462 */
463 recalculatePages(): void;
464 /**
465 * Body triggered a page event.
466 */
467 onBodyPage({ offset }: any): void;
468 /**
469 * The body triggered a scroll event.
470 */
471 onBodyScroll(event: MouseEvent): void;
472 /**
473 * The footer triggered a page event.
474 */
475 onFooterPage(event: any): void;
476 /**
477 * Recalculates the sizes of the page
478 */
479 calcPageSize(val?: any[]): number;
480 /**
481 * Calculates the row count.
482 */
483 calcRowCount(val?: any[]): number;
484 /**
485 * The header triggered a contextmenu event.
486 */
487 onColumnContextmenu({ event, column }: any): void;
488 /**
489 * The body triggered a contextmenu event.
490 */
491 onRowContextmenu({ event, row }: any): void;
492 /**
493 * The header triggered a column resize event.
494 */
495 onColumnResize({ column, newValue }: any): void;
496 /**
497 * The header triggered a column re-order event.
498 */
499 onColumnReorder({ column, newValue, prevValue }: any): void;
500 /**
501 * The header triggered a column sort event.
502 */
503 onColumnSort(event: any): void;
504 /**
505 * Toggle all row selection
506 */
507 onHeaderSelect(event: any): void;
508 /**
509 * A row was selected from body
510 */
511 onBodySelect(event: any): void;
512 /**
513 * A row was expanded or collapsed for tree
514 */
515 onTreeAction(event: any): void;
516 ngOnDestroy(): void;
517 /**
518 * listen for changes to input bindings of all DataTableColumnDirective and
519 * trigger the columnTemplates.changes observable to emit
520 */
521 private listenForColumnInputChanges;
522 private sortInternalRows;
523 static ɵfac: i0.ɵɵFactoryDeclaration<DatatableComponent, [{ skipSelf: true; }, { skipSelf: true; }, null, null, null, null, { optional: true; }]>;
524 static ɵcmp: i0.ɵɵComponentDeclaration<DatatableComponent, "ngx-datatable", never, { "targetMarkerTemplate": "targetMarkerTemplate"; "rows": "rows"; "groupRowsBy": "groupRowsBy"; "groupedRows": "groupedRows"; "columns": "columns"; "selected": "selected"; "scrollbarV": "scrollbarV"; "scrollbarH": "scrollbarH"; "rowHeight": "rowHeight"; "columnMode": "columnMode"; "headerHeight": "headerHeight"; "footerHeight": "footerHeight"; "externalPaging": "externalPaging"; "externalSorting": "externalSorting"; "limit": "limit"; "count": "count"; "offset": "offset"; "loadingIndicator": "loadingIndicator"; "selectionType": "selectionType"; "reorderable": "reorderable"; "swapColumns": "swapColumns"; "sortType": "sortType"; "sorts": "sorts"; "cssClasses": "cssClasses"; "messages": "messages"; "rowClass": "rowClass"; "selectCheck": "selectCheck"; "displayCheck": "displayCheck"; "groupExpansionDefault": "groupExpansionDefault"; "trackByProp": "trackByProp"; "selectAllRowsOnPage": "selectAllRowsOnPage"; "virtualization": "virtualization"; "treeFromRelation": "treeFromRelation"; "treeToRelation": "treeToRelation"; "summaryRow": "summaryRow"; "summaryHeight": "summaryHeight"; "summaryPosition": "summaryPosition"; "rowIdentity": "rowIdentity"; }, { "scroll": "scroll"; "activate": "activate"; "select": "select"; "sort": "sort"; "page": "page"; "reorder": "reorder"; "resize": "resize"; "tableContextmenu": "tableContextmenu"; "treeAction": "treeAction"; }, ["rowDetail", "groupHeader", "footer", "columnTemplates"], never>;
525}