Skip to content

Commit

Permalink
fix #540
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Aug 9, 2016
1 parent 4de7ac1 commit 825ca76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,15 @@ class BootstrapTable extends Component {
const { options, pagination } = this.props;
const sortName = options.defaultSortName || options.sortName;
const sortOrder = options.defaultSortOrder || options.sortOrder;
const searchText = options.defaultSearch;
if (sortName && sortOrder) {
this.store.sort(sortOrder, sortName);
}

if (searchText) {
this.store.search(searchText);
}

if (pagination) {
let page;
let sizePerPage;
Expand Down Expand Up @@ -788,6 +793,7 @@ class BootstrapTable extends Component {
return (
<div className='react-bs-table-tool-bar'>
<ToolBar
defaultSearch={ this.props.options.defaultSearch }
clearSearch={ this.props.options.clearSearch }
searchDelayTime={ this.props.options.searchDelayTime }
enableInsert={ insertRow }
Expand Down Expand Up @@ -983,7 +989,8 @@ BootstrapTable.propTypes = {
deleteText: PropTypes.string,
saveText: PropTypes.string,
closeText: PropTypes.string,
ignoreEditable: PropTypes.bool
ignoreEditable: PropTypes.bool,
defaultSearch: PropTypes.string
}),
fetchInfo: PropTypes.shape({
dataTotalSize: PropTypes.number
Expand Down Expand Up @@ -1068,7 +1075,8 @@ BootstrapTable.defaultProps = {
deleteText: Const.DELETE_BTN_TEXT,
saveText: Const.SAVE_BTN_TEXT,
closeText: Const.CLOSE_BTN_TEXT,
ignoreEditable: false
ignoreEditable: false,
defaultSearch: ''
},
fetchInfo: {
dataTotalSize: 0
Expand Down
4 changes: 3 additions & 1 deletion src/toolbar/ToolBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class ToolBar extends Component {
<input ref='seachInput'
className='form-control'
type='text'
defaultValue={ this.props.defaultSearch }
placeholder={ this.props.searchPlaceholder ? this.props.searchPlaceholder : 'Search' }
onKeyUp={ this.handleKeyUp }/>
{ clearBtn }
Expand Down Expand Up @@ -379,7 +380,8 @@ ToolBar.propTypes = {
saveText: PropTypes.string,
closeText: PropTypes.string,
clearSearch: PropTypes.bool,
ignoreEditable: PropTypes.bool
ignoreEditable: PropTypes.bool,
defaultSearch: PropTypes.string
};

ToolBar.defaultProps = {
Expand Down

0 comments on commit 825ca76

Please sign in to comment.