Skip to content

Commit

Permalink
fix #57
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Sep 23, 2015
1 parent f463a68 commit 260a1a4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
16 changes: 11 additions & 5 deletions example/js/demo.bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions example/js/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function onAfterInsertRow(row){
var selectRowProp = {
mode: "checkbox",
clickToSelect: true,
// hideSelectColumn: true, //you can hide select column, if you enable clickToSelect
selected: [], //default select on table
bgColor: "rgb(238, 193, 213)",
onSelect: onRowSelect,
Expand Down
3 changes: 3 additions & 0 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class BootstrapTable extends React.Component{
{toolBar}
<div ref="table" style={style} className={tableClass}>
<TableHeader rowSelectType={this.props.selectRow.mode}
hideSelectColumn={this.props.selectRow.hideSelectColumn}
sortName={this.props.options.sortName}
sortOrder={this.props.options.sortOrder}
onSort={this.handleSort.bind(this)}
Expand Down Expand Up @@ -386,6 +387,7 @@ BootstrapTable.propTypes = {
onSelect: React.PropTypes.func,
onSelectAll: React.PropTypes.func,
clickToSelect: React.PropTypes.bool,
hideSelectColumn: React.PropTypes.bool,
clickToSelectAndEditCell: React.PropTypes.bool
}),
cellEdit: React.PropTypes.shape({
Expand Down Expand Up @@ -419,6 +421,7 @@ BootstrapTable.defaultProps = {
onSelect: undefined,
onSelectAll: undefined,
clickToSelect: false,
hideSelectColumn: false,
clickToSelectAndEditCell: false
},
cellEdit:{
Expand Down
7 changes: 5 additions & 2 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class TableBody extends React.Component{
}
}, this);
var selected = this.props.selectedRowKeys.indexOf(data[this.props.keyField]) != -1;
var selectRowColumn = isSelectRowDefined?this.renderSelectRowColumn(selected):null;
var selectRowColumn = isSelectRowDefined && !this.props.selectRow.hideSelectColumn?
this.renderSelectRowColumn(selected):null;
return (
<TableRow isSelected={selected} key={r}
selectRow={isSelectRowDefined?this.props.selectRow:undefined}
Expand Down Expand Up @@ -118,7 +119,7 @@ class TableBody extends React.Component{
let style = {
width:35
}
selectRowHeader = (<th style={style} key={-1}></th>);
selectRowHeader = this.props.selectRow.hideSelectColumn?null:(<th style={style} key={-1}></th>);
}
var theader = this.props.columns.map(function(column, i){
let style={
Expand Down Expand Up @@ -157,6 +158,8 @@ class TableBody extends React.Component{
this.editing = true;
if(this._isSelectRowDefined()){
columnIndex--;
if(this.props.selectRow.hideSelectColumn)
columnIndex++;
}
rowIndex--;
var stateObj = {
Expand Down
5 changes: 3 additions & 2 deletions src/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TableHeader extends React.Component{

render(){
var containerClasses = classSet("table-header");
var selectRowHeaderCol = this.renderSelectRowHeader();
var selectRowHeaderCol = this.props.hideSelectColumn?null:this.renderSelectRowHeader();
this._attachClearSortCaretFunc();

return(
Expand Down Expand Up @@ -82,7 +82,8 @@ TableHeader.propTypes = {
onSort: React.PropTypes.func,
onSelectAllRow: React.PropTypes.func,
sortName: React.PropTypes.string,
sortOrder: React.PropTypes.string
sortOrder: React.PropTypes.string,
hideSelectColumn: React.PropTypes.bool
};

TableHeader.defaultProps = {
Expand Down

0 comments on commit 260a1a4

Please sign in to comment.