Skip to content

Instantly share code, notes, and snippets.

@mbuckley
Created August 31, 2017 19:14
Show Gist options
  • Save mbuckley/b216dd17a177a8038ed57e97838fe22e to your computer and use it in GitHub Desktop.
Save mbuckley/b216dd17a177a8038ed57e97838fe22e to your computer and use it in GitHub Desktop.
DatatableExportService Usage Example
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