3

I am working with react-bootstrap-table and I am facing problems with formatting it. Main issues are:

  • the headers with long names should be presented with 2 lines of text, instead there is one and "..." like in the picture below: enter image description here

  • Moreover in no way I could set the height of a single row of a table. Each text has big padding therefore the table is not too condensed: enter image description here

And the code goes here:

<BootstrapTable
   data={this.props.sales}
   version="4"
   striped
   hover
   pagination
   keyField="Type"
>
  {tableHeaders.map((header, index) => (
     <TableHeaderColumn key={index} dataField={header.id} style={{ height: 10 }}>
        {header.name}
     </TableHeaderColumn>
  ))}
</BootstrapTable>
3
  • its a css problem with text overflowing Commented Aug 16, 2018 at 13:12
  • inspect element. go the css class style. you may find code like this ... text-overflow: ellipsis; overflow: hidden; white-space: nowrap; just remove them from css and that's all Commented Aug 16, 2018 at 13:29
  • and let me know if still facing issue Commented Aug 16, 2018 at 13:30

1 Answer 1

5

According to docs you can do all of the customizations you need.

First issue: To remove dots you can use thStyle property which you can pass to TableHeaderColumn component and override CSS white-space property.

<TableHeaderColumn thStyle={{ whiteSpace: 'normal' }} {...anotherProps} />

Second issue: You can handle height of your row using trClassName property. You can either pass string or function to handle each or make conditional class depends on row. See more here.

For example:

<BootstrapTable trClassName="customClass" {...anotherProps} />

And define your customClass:

.customClass {
    // override padding or height whatever you want 
    padding: 3px;
}

Good luck and have fun!

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, both issue solved. To anyone struggling with second case - we have to use line-height property

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.