Skip to content

Commit

Permalink
fix #1619 for table condensed
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Oct 16, 2017
1 parent 9f64cdf commit 137a6b2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ class TableBody extends Component {

render() {
const { cellEdit, beforeShowError, x, y, keyBoardNav, trStyle, version } = this.props;
const tableClasses = classSet('table', {
const customTableClasses = {
'table-striped': this.props.striped,
'table-bordered': this.props.bordered,
'table-hover': this.props.hover,
'table-condensed': this.props.condensed
}, this.props.tableBodyClass);
'table-hover': this.props.hover
};
if (this.props.condensed) {
if (Utils.isBootstrap4(version)) customTableClasses['table-sm'] = true;
else customTableClasses['table-condensed'] = true;
}
const tableClasses = classSet('table', customTableClasses, this.props.tableBodyClass);

const noneditableRows = (cellEdit.nonEditableRows && cellEdit.nonEditableRows()) || [];
const unselectable = this.props.selectRow.unselectable || [];
Expand Down
16 changes: 11 additions & 5 deletions src/TableHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Const from './Const';
import classSet from 'classnames';
import SelectRowHeaderColumn from './SelectRowHeaderColumn';
import ExpandRowHeaderColumn from './ExpandRowHeaderColumn';
import Utils from './util';

class Checkbox extends Component {
componentDidMount() { this.update(this.props.checked); }
Expand Down Expand Up @@ -37,14 +38,20 @@ function getSortOrder(sortList, field, enableSort) {
class TableHeader extends Component {

render() {
const { sortIndicator, sortList, onSort, reset, version, condensed, bordered } = this.props;
const containerClasses = classSet(
'react-bs-container-header',
'table-header-wrapper',
this.props.headerContainerClass);
const tableClasses = classSet('table', 'table-hover', {
'table-bordered': this.props.bordered,
'table-condensed': this.props.condensed
}, this.props.tableHeaderClass);
const customTableClasses = {
'table-bordered': bordered
};
if (condensed) {
if (Utils.isBootstrap4(version)) customTableClasses['table-sm'] = true;
else customTableClasses['table-condensed'] = true;
}
const tableClasses = classSet(
'table', 'table-hover', customTableClasses, this.props.tableHeaderClass);

const rowCount = Math.max(...React.Children.map(this.props.children, elm =>
(elm && elm.props.row) ? Number(elm.props.row) : 0
Expand All @@ -65,7 +72,6 @@ class TableHeader extends Component {
!this.props.expandColumnBeforeSelectColumn &&
<ExpandRowHeaderColumn rowCount={ rowCount + 1 }/>
]);
const { sortIndicator, sortList, onSort, reset, version } = this.props;

React.Children.forEach(this.props.children, (elm) => {
if (elm === null || elm === undefined) {
Expand Down

0 comments on commit 137a6b2

Please sign in to comment.