react-bootstrap-table icon indicating copy to clipboard operation
react-bootstrap-table copied to clipboard

Dynamically adjust height of table?

Open Dreculah opened this issue 10 years ago • 3 comments

Hi,

I see that height is a prop right now, so it can't be directly changed.

We have a requirement to change the height of the table dynamically after its rendered.

Would it be possible to expose a setHeight(), perhaps by making height state vs prop?

Thanks!

Dreculah avatar Apr 20 '16 01:04 Dreculah

so according your description, I think the following is not your expectation?

export default class BasicTable extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      height: '120'
    };
  }

  handleHeightChange = () => {
    this.setState({
      height: '300'
    });
  }

  render() {
    return (
      <div>
        <button onClick={ this.handleHeightChange }>Change height</button>
        <BootstrapTable data={ products } height={ this.state.height }>
            <TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
            <TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
            <TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
        </BootstrapTable>
      </div>
    );
  }
}

if right, I can try to expose a setHeight on BootstrapTable :) Hope it's easy to implement :)

AllenFang avatar Apr 20 '16 02:04 AllenFang

Actually, this works fine...sorry for the newb question, and please close.

Thanks!

Dreculah avatar Apr 20 '16 16:04 Dreculah

@Dreculah, that's fine, no worry 👍

AllenFang avatar Apr 20 '16 16:04 AllenFang