Skip to content

Commit 825ca76

Browse files
committed
fix #540
1 parent 4de7ac1 commit 825ca76

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/BootstrapTable.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,15 @@ class BootstrapTable extends Component {
9797
const { options, pagination } = this.props;
9898
const sortName = options.defaultSortName || options.sortName;
9999
const sortOrder = options.defaultSortOrder || options.sortOrder;
100+
const searchText = options.defaultSearch;
100101
if (sortName && sortOrder) {
101102
this.store.sort(sortOrder, sortName);
102103
}
103104

105+
if (searchText) {
106+
this.store.search(searchText);
107+
}
108+
104109
if (pagination) {
105110
let page;
106111
let sizePerPage;
@@ -788,6 +793,7 @@ class BootstrapTable extends Component {
788793
return (
789794
<div className='react-bs-table-tool-bar'>
790795
<ToolBar
796+
defaultSearch={ this.props.options.defaultSearch }
791797
clearSearch={ this.props.options.clearSearch }
792798
searchDelayTime={ this.props.options.searchDelayTime }
793799
enableInsert={ insertRow }
@@ -983,7 +989,8 @@ BootstrapTable.propTypes = {
983989
deleteText: PropTypes.string,
984990
saveText: PropTypes.string,
985991
closeText: PropTypes.string,
986-
ignoreEditable: PropTypes.bool
992+
ignoreEditable: PropTypes.bool,
993+
defaultSearch: PropTypes.string
987994
}),
988995
fetchInfo: PropTypes.shape({
989996
dataTotalSize: PropTypes.number
@@ -1068,7 +1075,8 @@ BootstrapTable.defaultProps = {
10681075
deleteText: Const.DELETE_BTN_TEXT,
10691076
saveText: Const.SAVE_BTN_TEXT,
10701077
closeText: Const.CLOSE_BTN_TEXT,
1071-
ignoreEditable: false
1078+
ignoreEditable: false,
1079+
defaultSearch: ''
10721080
},
10731081
fetchInfo: {
10741082
dataTotalSize: 0

src/toolbar/ToolBar.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ class ToolBar extends Component {
279279
<input ref='seachInput'
280280
className='form-control'
281281
type='text'
282+
defaultValue={ this.props.defaultSearch }
282283
placeholder={ this.props.searchPlaceholder ? this.props.searchPlaceholder : 'Search' }
283284
onKeyUp={ this.handleKeyUp }/>
284285
{ clearBtn }
@@ -379,7 +380,8 @@ ToolBar.propTypes = {
379380
saveText: PropTypes.string,
380381
closeText: PropTypes.string,
381382
clearSearch: PropTypes.bool,
382-
ignoreEditable: PropTypes.bool
383+
ignoreEditable: PropTypes.bool,
384+
defaultSearch: PropTypes.string
383385
};
384386

385387
ToolBar.defaultProps = {

0 commit comments

Comments
 (0)