Skip to content

Commit

Permalink
Merge pull request mbrn#2335 from TeamDiverst/remove_pdf
Browse files Browse the repository at this point in the history
allow control over export buttons
  • Loading branch information
mbrn authored Aug 23, 2020
2 parents 6b2e168 + 1a4a048 commit 2384f5a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
18 changes: 11 additions & 7 deletions src/components/m-table-toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,16 @@ export class MTableToolbar extends React.Component {
open={Boolean(this.state.exportButtonAnchorEl)}
onClose={() => this.setState({ exportButtonAnchorEl: null })}
>
<MenuItem key="export-csv" onClick={this.exportCsv}>
{localization.exportCSVName}
</MenuItem>
<MenuItem key="export-pdf" onClick={this.exportPdf}>
{localization.exportPDFName}
</MenuItem>
{(this.props.exportButton === true || this.props.exportButton.csv ) && (
<MenuItem key="export-csv" onClick={this.exportCsv}>
{localization.exportCSVName}
</MenuItem>
)}
{(this.props.exportButton === true || this.props.exportButton.pdf ) && (
<MenuItem key="export-pdf" onClick={this.exportPdf}>
{localization.exportPDFName}
</MenuItem>
)}
</Menu>
</span>
)}
Expand Down Expand Up @@ -419,7 +423,7 @@ MTableToolbar.propTypes = {
renderData: PropTypes.array,
data: PropTypes.array,
exportAllData: PropTypes.bool,
exportButton: PropTypes.bool,
exportButton: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({ csv: PropTypes.bool, pdf: PropTypes.bool })]),
exportDelimiter: PropTypes.string,
exportFileName: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
exportCsv: PropTypes.func,
Expand Down
5 changes: 4 additions & 1 deletion src/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ export const propTypes = {
doubleHorizontalScroll: PropTypes.bool,
emptyRowsWhenPaging: PropTypes.bool,
exportAllData: PropTypes.bool,
exportButton: PropTypes.bool,
exportButton: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.shape({ csv: PropTypes.bool, pdf: PropTypes.bool }),
]),
exportDelimiter: PropTypes.string,
exportFileName: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
exportCsv: PropTypes.func,
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export interface Options<RowData extends object> {
draggable?: boolean;
emptyRowsWhenPaging?: boolean;
exportAllData?: boolean;
exportButton?: boolean;
exportButton?: boolean | { csv?: boolean; pdf?: boolean };
exportDelimiter?: string;
exportFileName?:
| string
Expand Down

0 comments on commit 2384f5a

Please sign in to comment.