Skip to content

Commit

Permalink
Allow injecting additional thead rows before and after the generated …
Browse files Browse the repository at this point in the history
…header row. (Valid tables can have a multiple tbody elements but only a single thead and tfoot. Therefore additional rows need to be injected into the exisiting Header component.)
  • Loading branch information
leoek committed Jul 5, 2021
1 parent ef22dc4 commit 7fca9b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/react-bootstrap-table2/src/bootstrap-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class BootstrapTable extends PropsBaseResolver(Component) {
<div className={ tableWrapperClass }>
<table id={ id } className={ tableClass }>
{ tableCaption }
{this.props.preHeader}
<Header
columns={ columns }
className={ this.props.headerClasses }
Expand All @@ -105,7 +106,10 @@ class BootstrapTable extends PropsBaseResolver(Component) {
selectRow={ selectRow }
expandRow={ expandRow }
filterPosition={ filterPosition }
preHeaderRow={ this.props.preHeaderRow }
postHeaderRow={ this.props.postHeaderRow }
/>
{this.props.postHeader}
{hasFilters && filterPosition !== Const.FILTERS_POSITION_INLINE && (
<Filters
columns={ columns }
Expand Down Expand Up @@ -255,7 +259,9 @@ BootstrapTable.propTypes = {
searchText: PropTypes.string,
searchContext: PropTypes.func
}),
setDependencyModules: PropTypes.func
setDependencyModules: PropTypes.func,
preHeaderRow: PropTypes.node,
postHeaderRow: PropTypes.node
};

BootstrapTable.defaultProps = {
Expand Down
15 changes: 13 additions & 2 deletions packages/react-bootstrap-table2/src/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const Header = (props) => {
onExternalFilter,
filterPosition,
globalSortCaret,
wrapperClasses
wrapperClasses,
preHeaderRow,
postHeaderRow
} = props;

let SelectionHeaderCellComp = () => null;
Expand Down Expand Up @@ -82,9 +84,11 @@ const Header = (props) => {

return (
<thead className={ wrapperClasses }>
{preHeaderRow}
<tr className={ className }>
{ childrens }
</tr>
{postHeaderRow}
</thead>
);
};
Expand All @@ -106,7 +110,14 @@ Header.propTypes = {
Const.FILTERS_POSITION_TOP,
Const.FILTERS_POSITION_INLINE,
Const.FILTERS_POSITION_BOTTOM
])
]),
preHeaderRow: PropTypes.node,
postHeaderRow: PropTypes.node
};

Header.defaultProps = {
preHeaderRow: null,
postHeaderRow: null
};

export default Header;

0 comments on commit 7fca9b8

Please sign in to comment.