Added events to tie into beginning/ending of processing

This commit is contained in:
Zakary Timson 2018-06-28 19:22:01 -04:00
parent 7ee1eda2f0
commit da9e3960e2
2 changed files with 7 additions and 1 deletions

View File

@ -64,12 +64,14 @@ Selector: `ng-datatable`
| @Input() pageLength: number | Number of rows per page. Default 20 | | @Input() pageLength: number | Number of rows per page. Default 20 |
| @Input() page: number | Current page | | @Input() page: number | Current page |
| @Input() paginate: boolean | Paginate rows or display all at once. Default true | | @Input() paginate: boolean | Paginate rows or display all at once. Default true |
| @Input() paginateCssClass: string | Class added to the paginator | @Input() paginateCssClass: string | Class added to the paginator |
| @Input() selectionMode: null/'single'/'multi' | Allow selecting none, single or multiple rows at once | | @Input() selectionMode: null/'single'/'multi' | Allow selecting none, single or multiple rows at once |
| @Input() showCheckbox: boolean | Show checkbox' for mass selecting | | @Input() showCheckbox: boolean | Show checkbox' for mass selecting |
| @Input() tableLayout: 'auto'/'fixed' | CSS table layout. Defaults to 'auto' | | @Input() tableLayout: 'auto'/'fixed' | CSS table layout. Defaults to 'auto' |
| @Output() filterChanged: EventEmitter<(a, b) => 1/0/-1[]> | Applied filters | | @Output() filterChanged: EventEmitter<(a, b) => 1/0/-1[]> | Applied filters |
| @Output() finished: EventEmitter<any[]> | Emits when finished processing data |
| @Output() pageChanged: EventEmitter<number> | New page | | @Output() pageChanged: EventEmitter<number> | New page |
| @Output() processing: EventEmitter<any[]> | Emits when processing begins
| @Output() selectionChanged: EventEmitter<any[]> | Selected rows | | @Output() selectionChanged: EventEmitter<any[]> | Selected rows |
| pagedData: any[] | Array of rows on current page after sorting and filtering | | pagedData: any[] | Array of rows on current page after sorting and filtering |
| processedData: any[] | Array of remaining rows after sorting and filtering | | processedData: any[] | Array of remaining rows after sorting and filtering |

View File

@ -22,7 +22,9 @@ export class NgDatatableComponent implements OnInit {
// Outputs =========================================================================================================== // Outputs ===========================================================================================================
@Output() filterChanged = new EventEmitter<any[]>(); // Output when filters change @Output() filterChanged = new EventEmitter<any[]>(); // Output when filters change
@Output() finished = new EventEmitter<any[]>(); // Fired after processing is finished
@Output() pageChanged = new EventEmitter<number>(); // Output when page is changed @Output() pageChanged = new EventEmitter<number>(); // Output when page is changed
@Output() processing = new EventEmitter<any[]>(); // Fires when grid begins to process
@Output() selectionChanged = new EventEmitter<any[]>(); // Output when selected rows changes @Output() selectionChanged = new EventEmitter<any[]>(); // Output when selected rows changes
// Properties ======================================================================================================== // Properties ========================================================================================================
@ -59,6 +61,7 @@ export class NgDatatableComponent implements OnInit {
// Helpers =========================================================================================================== // Helpers ===========================================================================================================
private _process() { private _process() {
this.processing.emit(this.processedData);
this.clearSelected(); this.clearSelected();
this.processedData = this._data; this.processedData = this._data;
this.filters.forEach(f => this.processedData = this.processedData.filter(f)); this.filters.forEach(f => this.processedData = this.processedData.filter(f));
@ -83,6 +86,7 @@ export class NgDatatableComponent implements OnInit {
} else { } else {
this.pagedData = this.processedData; this.pagedData = this.processedData;
} }
this.finished.emit(this.processedData);
} }
_convertWidth(width) { _convertWidth(width) {