@@ -6,6 +6,7 @@ import PropTypes from 'prop-types';
66import cs from 'classnames' ;
77
88import Header from './header' ;
9+ import Filters from './filters' ;
910import Caption from './caption' ;
1011import Body from './body' ;
1112import Footer from './footer' ;
@@ -65,7 +66,8 @@ class BootstrapTable extends PropsBaseResolver(Component) {
6566 rowEvents,
6667 selectRow,
6768 expandRow,
68- cellEdit
69+ cellEdit,
70+ filterPosition
6971 } = this . props ;
7072
7173 const tableWrapperClass = cs ( 'react-bootstrap-table' , wrapperClasses ) ;
@@ -77,6 +79,8 @@ class BootstrapTable extends PropsBaseResolver(Component) {
7779 [ bootstrap4 ? 'table-sm' : 'table-condensed' ] : condensed
7880 } , classes ) ;
7981
82+ const hasFilters = columns . some ( col => col . filter || col . filterRenderer ) ;
83+
8084 const hasFooter = _ . filter ( columns , col => _ . has ( col , 'footer' ) ) . length > 0 ;
8185
8286 const tableCaption = ( caption && < Caption > { caption } </ Caption > ) ;
@@ -96,7 +100,19 @@ class BootstrapTable extends PropsBaseResolver(Component) {
96100 onExternalFilter = { this . props . onExternalFilter }
97101 selectRow = { selectRow }
98102 expandRow = { expandRow }
103+ filterPosition = { filterPosition }
99104 />
105+ { hasFilters && filterPosition !== Const . FILTERS_POSITION_INLINE && (
106+ < Filters
107+ columns = { columns }
108+ className = { this . props . filtersClasses }
109+ onSort = { this . props . onSort }
110+ onFilter = { this . props . onFilter }
111+ currFilters = { this . props . currFilters }
112+ filterPosition = { this . props . filterPosition }
113+ onExternalFilter = { this . props . onExternalFilter }
114+ />
115+ ) }
100116 < Body
101117 data = { this . getData ( ) }
102118 keyField = { keyField }
@@ -135,7 +151,7 @@ BootstrapTable.propTypes = {
135151 remote : PropTypes . oneOfType ( [ PropTypes . bool , PropTypes . shape ( {
136152 pagination : PropTypes . bool
137153 } ) ] ) ,
138- noDataIndication : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . func ] ) ,
154+ noDataIndication : PropTypes . oneOfType ( [ PropTypes . node , PropTypes . func ] ) ,
139155 striped : PropTypes . bool ,
140156 bordered : PropTypes . bool ,
141157 hover : PropTypes . bool ,
@@ -199,6 +215,12 @@ BootstrapTable.propTypes = {
199215 rowEvents : PropTypes . object ,
200216 rowClasses : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . func ] ) ,
201217 headerClasses : PropTypes . string ,
218+ filtersClasses : PropTypes . string ,
219+ filterPosition : PropTypes . oneOf ( [
220+ Const . FILTERS_POSITION_TOP ,
221+ Const . FILTERS_POSITION_INLINE ,
222+ Const . FILTERS_POSITION_BOTTOM
223+ ] ) ,
202224 footerClasses : PropTypes . string ,
203225 defaultSorted : PropTypes . arrayOf ( PropTypes . shape ( {
204226 dataField : PropTypes . string . isRequired ,
@@ -240,7 +262,8 @@ BootstrapTable.defaultProps = {
240262 cellEdit : {
241263 mode : null ,
242264 nonEditableRows : [ ]
243- }
265+ } ,
266+ filterPosition : Const . FILTERS_POSITION_INLINE
244267} ;
245268
246269export default BootstrapTable ;
0 commit comments