From a28088b1e4adf03d6aa82a7b5b3af7385586b40d Mon Sep 17 00:00:00 2001 From: Walter Bonetti Date: Wed, 13 Apr 2022 17:02:55 -0400 Subject: [PATCH] allow to disable bulk edit via isBulkEditable func (#526) --- src/material-table.js | 2 ++ src/prop-types.js | 1 + types/index.d.ts | 1 + 3 files changed, 4 insertions(+) diff --git a/src/material-table.js b/src/material-table.js index 900bbe01..84349b63 100644 --- a/src/material-table.js +++ b/src/material-table.js @@ -383,6 +383,8 @@ export default class MaterialTable extends React.Component { tooltip: localization.bulkEditTooltip, position: 'toolbar', hidden: this.dataManager.bulkEditOpen, + disabled: + calculatedProps.isBulkEditable && calculatedProps.isBulkEditable(), onClick: () => { this.dataManager.changeBulkEditOpen(true); this.props.onBulkEditOpen && this.props.onBulkEditOpen(true); diff --git a/src/prop-types.js b/src/prop-types.js index 1e8773b7..188e32c5 100644 --- a/src/prop-types.js +++ b/src/prop-types.js @@ -183,6 +183,7 @@ export const propTypes = { ]).isRequired, editable: PropTypes.shape({ isEditable: PropTypes.func, + isBulkEditable: PropTypes.func, isDeletable: PropTypes.func, onRowAdd: PropTypes.func, onRowUpdate: PropTypes.func, diff --git a/types/index.d.ts b/types/index.d.ts index 8720b3b6..b1870c69 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -29,6 +29,7 @@ export interface MaterialTableProps { | (DetailPanel | ((rowData: RowData) => DetailPanel))[]; editable?: { isEditable?: (rowData: RowData) => boolean; + isBulkEditable?: () => boolean; isDeletable?: (rowData: RowData) => boolean; onBulkUpdate?: ( changes: Record