Skip to content

Commit

Permalink
add max height feature
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Dec 28, 2015
1 parent 159b8f3 commit 91bcf2a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class BootstrapTable extends React.Component {
var tableClass = classSet("react-bs-table");
var childrens = this.props.children;
var style = {
height: this.props.height
height: this.props.height,
maxHeight: this.props.maxHeight
};
if (!Array.isArray(this.props.children)) {
childrens = [this.props.children];
Expand Down Expand Up @@ -206,6 +207,7 @@ class BootstrapTable extends React.Component {
</TableHeader>
<TableBody
height={this.props.height}
maxHeight={this.props.maxHeight}
ref="body"
data={this.state.data}
columns={columns}
Expand Down Expand Up @@ -576,6 +578,7 @@ class BootstrapTable extends React.Component {
BootstrapTable.propTypes = {
keyField: React.PropTypes.string,
height: React.PropTypes.string,
maxHeight: React.PropTypes.string,
data: React.PropTypes.oneOfType([React.PropTypes.array, React.PropTypes.object]),
remote: React.PropTypes.bool, // remote data, default is false
striped: React.PropTypes.bool,
Expand Down Expand Up @@ -630,6 +633,7 @@ BootstrapTable.propTypes = {
};
BootstrapTable.defaultProps = {
height: "100%",
maxHeight: undefined,
striped: false,
bordered: true,
hover: false,
Expand Down
5 changes: 5 additions & 0 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ class TableBody extends React.Component{
if(this.props.condensed) {
this.refs.body.style.marginTop = "-36px";
}

if(this.props.maxHeight &&
parseInt(this.props.maxHeight) < this.refs.container.offsetHeight) {
this.refs.container.style.height = (this.props.maxHeight - 42) + "px";
}
}

hardFixHeaderWidth(){
Expand Down

0 comments on commit 91bcf2a

Please sign in to comment.