UNPKG

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