Skip to content

Commit

Permalink
add onDetailPanelChange callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Domino987 committed Nov 10, 2023
1 parent 652e6c8 commit 6c326fd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions __tests__/demo/demo-components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ export function DetailPanelRemounting(props) {
detailPanel={({ rowData }) => (
<SubTable rowData={rowData} setSelection={setSelection} />
)}
onDetailPanelChange={console.log}
options={{
selection: true
}}
Expand Down
8 changes: 7 additions & 1 deletion src/material-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,14 @@ export default class MaterialTable extends React.Component {
};

onToggleDetailPanel = (path, render) => {
this.dataManager.changeDetailPanelVisibility(path, render);
const row = this.dataManager.changeDetailPanelVisibility(path, render);
this.setState(this.dataManager.getRenderState());
console.log(row, row.tableData.showDetailPanel ? 'open' : 'closed');
this.props.onTreeExpandChange &&
this.props.onDetailPanelChange(
row,
row.tableData.showDetailPanel ? 'open' : 'closed'
);
};

onCellEditStarted = (rowData, columnDef) => {
Expand Down
1 change: 1 addition & 0 deletions src/utils/data-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export default class DataManager {
}

this.lastDetailPanelRow = rowData;
return rowData;
}

changeGroupExpand(path) {
Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface MaterialTableProps<RowData extends object> {
onTreeExpandChange?: (data: any, isExpanded: boolean) => void;
onQueryChange?: (query?: Query<RowData>) => void;
onBulkEditOpen?: (isOpen: boolean) => void;
onDetailPanelChange?: (row: RowData, state: 'open' | 'closed') => void;
renderSummaryRow?: ({
columns,
column,
Expand Down

0 comments on commit 6c326fd

Please sign in to comment.