React-bootstrap-table2: Responsive Table

Created on 16 Jan 2019  路  5Comments  路  Source: react-bootstrap-table/react-bootstrap-table2

I want horizontal scroll in my table. I have multiple columns and they look like they are stack up together. Any suggestions ?

Most helpful comment

Sorry to write in a closed issue, but other people like me may be still searching for the answer.
I solved it like follows:

  • Using this style as @theoryfarm pointed out:
.react-bootstrap-table table {
  table-layout: auto;
}
  • then setting the table like this:
<BootstrapTable
    keyField='id'
    data={tableData}
    columns={columns}
    pagination={paginationFactory()}
    striped
    bordered={false}
    wrapperClasses="table-responsive" // This is the style provided by bootstrap 4, this will set the parent div with that class
/>

I hope it helps.

All 5 comments

I think this can be fixed with css classes. Changing:

.react-bootstrap-table table {
table-layout: fixed;
}

TO

.react-bootstrap-table table {
table-layout: auto;
}

or add a class to the component that overrides it when you need it to behave differently than the default.

yeah it works, but I wish it could look better. I tried to center my table and table-layout: auto, but the tables still going to the right.

@theoryfarm thanks your answer. @juancafe4 i think we will not support horizontal scroll in near future. Instead, I'm much interesting to support vertical scroll on table, we have PR working on it but still faced some issue.

Anyway, PR is welcome, I'm also looking forward horizontal scrollable table 馃憤

Sorry to write in a closed issue, but other people like me may be still searching for the answer.
I solved it like follows:

  • Using this style as @theoryfarm pointed out:
.react-bootstrap-table table {
  table-layout: auto;
}
  • then setting the table like this:
<BootstrapTable
    keyField='id'
    data={tableData}
    columns={columns}
    pagination={paginationFactory()}
    striped
    bordered={false}
    wrapperClasses="table-responsive" // This is the style provided by bootstrap 4, this will set the parent div with that class
/>

I hope it helps.

@hielfx, thanks! This worked for me, but I had to add the "react-device-detect" to detect the device and then add the style.

  • Import react-device-detect

import {isMobile} from 'react-device-detect';

  • Check if a mobile device then add the style

if (isMobile) { require('../custom-styles/custom.css'); }

  • Content file custom.css:

.react-inicializa莽茫o-table mesa { table-layout : auto ; }

  • Component:

<BootstrapTable keyField='id' data={data} columns={columns} pagination={paginationFactory()} wrapperClasses="table-responsive" />

Was this page helpful?
0 / 5 - 0 ratings

Related issues

saifulss picture saifulss  路  4Comments

ethannkschneider picture ethannkschneider  路  3Comments

imtmh picture imtmh  路  3Comments

josefheld picture josefheld  路  3Comments

cnav007 picture cnav007  路  4Comments