Created
August 31, 2017 19:14
-
-
Save mbuckley/b216dd17a177a8038ed57e97838fe22e to your computer and use it in GitHub Desktop.
DatatableExportService Usage Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DataTableUserOptions } from "lib-ThemisUI/src/lib/thDataTable/data-table.interfaces"; | |
import { DatatableExportService } from "common/services/datatable-export-service/datatable-export.service"; | |
class DemoComponentController { | |
public dataTableOptions: DataTableUserOptions; | |
/* @ngInject */ | |
constructor( | |
private $q: angular.IQService, | |
private DatatableExportService: DatatableExportService, | |
) {} | |
public $onInit() { | |
this.initTableOptions(); | |
} | |
private initTableOptions() { | |
this.dataTableOptions = { | |
dataSource: // removed because this is just a gist | |
export: { | |
onExportApply: (filter, columns) => { | |
return this.$q((resolve) => { | |
this.export(filter, columns, resolve); | |
}); | |
}, | |
objectName: "export_name", //Applies name to the export modal. Defaulted to table | |
}, | |
} as DataTableUserOptions; | |
} | |
private export(filter: any, columns: any, resolve: Function) { | |
this.DatatableExportService.export("/api/v4/<resource_name>.csv?fields=id,other_field", resolve); | |
} | |
} | |
const DemoComponent = { | |
controller: DemoComponentController, | |
}; | |
export { | |
DemoComponent, | |
DemoComponentController | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment