From 0f8eab439d9511c5e12628515cfeca80074a3dfc Mon Sep 17 00:00:00 2001 From: Wlad Meixner Date: Thu, 9 Apr 2020 21:47:02 +0200 Subject: [PATCH] add CSV export options --- types/react-bootstrap-table-next/index.d.ts | 14 ++++++++ .../react-bootstrap-table2-toolkit/index.d.ts | 15 +++++++++ .../react-bootstrap-table2-toolkit-tests.tsx | 32 ++++++++++++++++++- 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/types/react-bootstrap-table-next/index.d.ts b/types/react-bootstrap-table-next/index.d.ts index ea52a41660..08bcb8333f 100644 --- a/types/react-bootstrap-table-next/index.d.ts +++ b/types/react-bootstrap-table-next/index.d.ts @@ -135,6 +135,20 @@ export interface ColumnDescription { footerTitle?: boolean; footerEvents?: { onClick: (e: any, column: ColumnDescription, columnIndex: number) => void }; footerAlign?: CellAlignment | ((column: ColumnDescription, colIndex: number) => CellAlignment); + + /** + * CSV Column options only used with the toolkit provider + */ + csvType?: String | Number; + csvFormatter?: ColumnFormatter; + /** + * csvText defaults to column.text + */ + csvText?: string; + /** + * Toggle column display in CSV export + */ + csvExport?: boolean; } /** diff --git a/types/react-bootstrap-table2-toolkit/index.d.ts b/types/react-bootstrap-table2-toolkit/index.d.ts index 2ba73d55bb..2a565e7ebf 100644 --- a/types/react-bootstrap-table2-toolkit/index.d.ts +++ b/types/react-bootstrap-table2-toolkit/index.d.ts @@ -33,6 +33,20 @@ export interface TableSearchProps { customMatchFunc?: (props: SearchMatchProps) => boolean; } +export interface CSVProps { + fileName?: string; + separator?: string; + ignoreHeader?: boolean; + noAutoBOM?: boolean; + /** + * default is text/plain;charset=utf-8 + */ + blobType?: string; + exportAll?: boolean; + onlyExportSelection?: boolean; + onlyExportFiltered?: boolean; +} + export interface TableToolkitProps { bootstrap4?: boolean; search?: TableSearchProps | boolean; @@ -41,6 +55,7 @@ export interface TableToolkitProps { ref?: any; columns: Array>; children: (props: ToolkitContextType) => JSX.Element; + exportCSV?: boolean | CSVProps; } export interface ToolkitContextType { diff --git a/types/react-bootstrap-table2-toolkit/react-bootstrap-table2-toolkit-tests.tsx b/types/react-bootstrap-table2-toolkit/react-bootstrap-table2-toolkit-tests.tsx index 9812c33e7e..633252185a 100644 --- a/types/react-bootstrap-table2-toolkit/react-bootstrap-table2-toolkit-tests.tsx +++ b/types/react-bootstrap-table2-toolkit/react-bootstrap-table2-toolkit-tests.tsx @@ -79,7 +79,7 @@ const productColumns: Array> = [ ]; /** - * Toolkit with custom search test test + * Toolkit with custom search test */ const CustomSearch = (props: InjectedSearchProps) => { @@ -102,3 +102,33 @@ render( , document.getElementById('app'), ); + +/** + * Toolkit CSV export test + */ + +render( + + {({ baseProps, searchProps }) => ( + <> + + + + )} + , + document.getElementById('app'), +);