Skip to content

Commit

Permalink
Fixed #1762 - DataTable hide expander when there are no children rows
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Jan 28, 2021
1 parent 570bade commit 080abdc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/components/datatable/BodyCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,24 @@ export class BodyCell extends Component {
});

if (this.props.expander) {
let iconClassName = classNames('p-row-toggler-icon pi pi-fw p-clickable', {'pi-chevron-down': this.props.expanded, 'pi-chevron-right': !this.props.expanded});
const iconClassName = classNames('p-row-toggler-icon pi pi-fw p-clickable', {'pi-chevron-down': this.props.expanded, 'pi-chevron-right': !this.props.expanded});
content = (
<button type="button" onClick={this.onExpanderClick} className="p-row-toggler p-link">
<span className={iconClassName}></span>
<Ripple />
</button>
);

if (this.props.body) {
const expanderProps = {
onClick: this.onExpanderClick,
className: "p-row-toggler p-link",
iconClassName,
defaultElement: content
};

content = this.props.body(this.props.rowData, { ...this.props, ...{expander: expanderProps} });
}
}
else if (this.props.selectionMode) {
let showSelection = true;
Expand Down

0 comments on commit 080abdc

Please sign in to comment.