Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Commit b76266d

Browse files
committed
feat(grid-download): download button with event
1 parent 4780f8e commit b76266d

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-datatable",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "An Angular 2 datatable, with pagination, sorting, expandable rows etc.",
55
"keywords": [
66
"angular",

src/components/header.template.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export const HEADER_TEMPLATE = `
1010
(click)="columnSelectorOpen = !columnSelectorOpen; $event.stopPropagation()" >
1111
<i class="fa fa-list fa-lg"></i>
1212
</button>
13+
<button *ngIf="dataTable.showDownloadButton" type="button" class="btn btn-default btn-sm download-button"
14+
(click)="dataTable.downloadItems()">
15+
<i class="fa fa-download fa-lg"></i>
16+
</button>
1317
<div class="column-selector-wrapper" (click)="$event.stopPropagation()">
1418
<div *ngIf="columnSelectorOpen" class="column-selector-box panel panel-default">
1519
<div *ngIf="dataTable.expandableRows" class="column-selector-fixed-column checkbox">

src/components/table.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class DataTable implements DataTableParams, OnInit {
5656
@Input() selectOnRowClick = false;
5757
@Input() autoReload = true;
5858
@Input() showReloading = false;
59+
@Input() showDownloadButton = false;
5960

6061
// UI state without input:
6162

@@ -207,6 +208,13 @@ export class DataTable implements DataTableParams, OnInit {
207208
});
208209
}
209210

211+
// Download
212+
@Output() download = new EventEmitter();
213+
214+
downloadItems(){
215+
this.download.emit(this._getRemoteParameters());
216+
}
217+
210218
// event handlers:
211219

212220
@Output() rowClick = new EventEmitter();

0 commit comments

Comments
 (0)