Skip to content

Commit

Permalink
fix #152
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Nov 25, 2015
1 parent 3d46d88 commit ee5e3f5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class BootstrapTable extends React.Component {
}

render() {

var tableClass = classSet("react-bs-table");
var childrens = this.props.children;
var style = {
Expand All @@ -176,6 +177,7 @@ class BootstrapTable extends React.Component {
var pagination = this.renderPagination();
var toolBar = this.renderToolBar();
var tableFilter = this.renderTableFilter(columns);
var isSelectAll = this.isSelectAll();
return (
<div className="react-bs-container" ref="table">
{toolBar}
Expand All @@ -189,7 +191,8 @@ class BootstrapTable extends React.Component {
onSort={this.handleSort.bind(this)}
onSelectAllRow={this.handleSelectAllRow.bind(this)}
bordered={this.props.bordered}
condensed={this.props.condensed}>
condensed={this.props.condensed}
isSelectAll={isSelectAll}>
{this.props.children}
</TableHeader>
<TableBody
Expand All @@ -216,6 +219,16 @@ class BootstrapTable extends React.Component {
)
}

isSelectAll(){
var defaultSelectRowKeys = this.store.getSelectedRowKeys();
var allRowKeys = this.store.getAllRowkey();
if(defaultSelectRowKeys.length !== allRowKeys.length){
return false;
} else {
return defaultSelectRowKeys.every(elm => allRowKeys.indexOf(elm)>-1);
}
}

handleSort(order, sortField) {
if (this.props.options.onSortChange) {
this.props.options.onSortChange(sortField, order, this.props);
Expand Down
8 changes: 6 additions & 2 deletions src/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ class TableHeader extends React.Component{
if(this.props.rowSelectType == Const.ROW_SELECT_SINGLE) {
return (<SelectRowHeaderColumn></SelectRowHeaderColumn>);
}else if(this.props.rowSelectType == Const.ROW_SELECT_MULTI){
return (<SelectRowHeaderColumn><input type="checkbox" onChange={this.props.onSelectAllRow}/></SelectRowHeaderColumn>);
return (<SelectRowHeaderColumn>
<input type="checkbox" onChange={this.props.onSelectAllRow} checked={this.props.isSelectAll}/>
</SelectRowHeaderColumn>
);
}else{
return null;
}
Expand Down Expand Up @@ -106,7 +109,8 @@ TableHeader.propTypes = {
sortOrder: React.PropTypes.string,
hideSelectColumn: React.PropTypes.bool,
bordered: React.PropTypes.bool,
condensed: React.PropTypes.bool
condensed: React.PropTypes.bool,
isSelectAll: React.PropTypes.bool
};

TableHeader.defaultProps = {
Expand Down

0 comments on commit ee5e3f5

Please sign in to comment.