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

Horizontal Scrolling

Open SamusPwns opened this issue 6 years ago • 26 comments

Hello,

Using react-bootstrap-table, when I set the width of the columns and they were larger than the viewport, the table created a horizontal scroll.

I just upgraded to react-bootstrap-table-2 and can't figure out how to replicate the functionality. It may be that I am using Bootstrap 4 which isnt compatible yet.

Am I missing something obvious. Any help would be greatly appreciated.

SamusPwns avatar Apr 02 '18 20:04 SamusPwns

+1

Bricon66 avatar Apr 05 '18 20:04 Bricon66

I totally understand this feature is very important, sorry about that it's already delay due to my personal job is crazy busy. We will work hard on it

AllenFang avatar Apr 06 '18 09:04 AllenFang

No worries man, you've done an awesome job w/ this library. Thanks.

As an FYI...here is some CSS that worked for my situation. Passing along in the event that it may help others.

.table { overflow: auto; display: block; table-layout: auto; }

Bricon66 avatar Apr 06 '18 15:04 Bricon66

@Bricon66 coool, thanks for sharing~~

AllenFang avatar Apr 09 '18 15:04 AllenFang

you can you wrapClasses property and set table-responsive bootstrap class...It helped for me.

dprodigalson avatar Sep 03 '18 12:09 dprodigalson

Hi @AllenFang - By any chance, is there any timeline associated with this horizontal scroll feature?

Thirunavukkarasu avatar Sep 04 '18 19:09 Thirunavukkarasu

wrapperClasses plus css of @Bricon66 worked for me!

paulalcabasa avatar Sep 27 '18 07:09 paulalcabasa

@Bricon66 with the large screen it has white space screen shot 2018-10-02 at 5 26 13 pm

hungdev avatar Oct 02 '18 10:10 hungdev

Any updates on this? Pretty important feature, I'd also love to get the ability to hook into the responsive breakpoint configuration for the table columns

denodaeus avatar Oct 22 '18 00:10 denodaeus

You can just add the one line css. .react-bootstrap-table{ overflow-x:auto !important; }

rohankk2 avatar Dec 03 '18 20:12 rohankk2

I have a table that has 20+ columns. How is it possible to render a table with that many columns and no horizontal scroll option? screen shot 2019-02-19 at 2 05 42 pm

F-Adam-B avatar Feb 19 '19 21:02 F-Adam-B

@Bricon66 with the large screen it has white space screen shot 2018-10-02 at 5 26 13 pm

Display attribute causing the extra whitespace. This CSS worked for me: .table{ overflow: auto; table-layout: auto !important; }

ErkinKurt avatar Apr 01 '19 15:04 ErkinKurt

This issue had been solved by #325. Issue can be closed.

The correct Bootstrap-way is

<div class="table-responsive">
  <tabe class="table"><!-- ... --></table>
</div>

And it can be done by following snipped

<BootstrapTable wrapperClasses="table-responsive" />

workgena avatar Jun 05 '19 14:06 workgena

I have a table that has 20+ columns. How is it possible to render a table with that many columns and no horizontal scroll option? screen shot 2019-02-19 at 2 05 42 pm

What solution did you use?

sunilsp77 avatar Jun 15 '20 07:06 sunilsp77

Hey, check snippet below. It works like responsive table from bootstrap.

<BootstrapTable
  bootstrap4
  wrapperClasses="table-responsive"
  rowClasses="text-nowrap"
/>

// somewhere in css
.react-bootstrap-table table {
  table-layout: auto;
}

shelooks16 avatar Sep 25 '20 14:09 shelooks16

I am using React Bootstrap Table and I want to add Horizontal Scrollbar only to the last two columns. Last two columns should be wrapped in a scrollable container. How can we implement this?

kunaltyagi9 avatar Sep 29 '20 07:09 kunaltyagi9

I am using React Bootstrap Table and I want to add Horizontal Scrollbar only to the last two columns. Last two columns should be wrapped in a scrollable container. How can we implement this?

I have same issue

xuanZo avatar Sep 30 '20 04:09 xuanZo

I am using React Bootstrap Table and I want to add Horizontal Scrollbar only to the last two columns. Last two columns should be wrapped in a scrollable container. How can we implement this?

I have same issue

Please share the solution, if you find one

kunaltyagi9 avatar Oct 01 '20 04:10 kunaltyagi9

I have a table that has 20+ columns. How is it possible to render a table with that many columns and no horizontal scroll option? screen shot 2019-02-19 at 2 05 42 pm

What solution did you use?

You can use the react-bootstrap-table.css instead of react-bootstrap-table.min.css and then set table layout as "auto" as mentioned by @ErkinKurt

vikramabhisheksah avatar Mar 08 '21 12:03 vikramabhisheksah

this works for me!

.react-bootstrap-table {
  overflow-x: auto;
}

.react-bootstrap-table .table {
  width: calc(100% - 3px);
}

Willywes avatar Sep 01 '21 03:09 Willywes

I am using the wrapper classes but my table is not responsive...any ideas? <BootStrapTable keyField="name" data={ data } wrapperClasses="table-responsive" rowClasses="text-nowrap" .....

jnemo44 avatar Sep 16 '21 02:09 jnemo44

New solution : not edit react-bootstrap-table2.css

in new css

 .div-horizontal {
  overflow: auto;
  white-space: nowrap;
}
.table {
  overflow: auto;
  table-layout: auto !important;
} 

Div Wrap BootStrapTable


 <div className="div-horizontal">
    <BootstrapTable
      bootstrap4
      keyField="KEY"
      data={valData}
      columns={columns}
      striped
      hover
      condensed
      ....
    />
  </div>

warinza avatar Oct 03 '21 09:10 warinza

New solution : not edit react-bootstrap-table2.css

in new css

 .div-horizontal {
  overflow: auto;
  white-space: nowrap;
}
.table {
  overflow: auto;
  table-layout: auto !important;
} 

Div Wrap BootStrapTable


 <div className="div-horizontal">
    <BootstrapTable
      bootstrap4
      keyField="KEY"
      data={valData}
      columns={columns}
      striped
      hover
      condensed
      ....
    />
  </div>

@warizna I'm having a problem,

When I use table-layout scrollbar doesn't appear, the table just goes off screen. And when I don't use it, scrollbar appears but the table, and the whole div gets squished .

Do you have any idea of the solution?

motherchucker avatar Oct 07 '21 09:10 motherchucker

Ok, I have found an issue that was causing table to not be responsive.

The problem was in some of the parent divs having a property: display: flex

I fixed it by adding a class: <div className: "container-fluid">

Maybe that helps someone.

Also, this solution mentioned above by @shelooks16 worked for me.

motherchucker avatar Oct 13 '21 15:10 motherchucker

Above solutions don't work in my environment. Now, it works by adding below values.

# css
.react-bootstrap-table table {
    width: max-content;
}

If you want to fix specific column width, you can add below values.

# <BootstrapTable>
headerStyle: {width: '50px'}

hanamurayuki avatar May 07 '22 11:05 hanamurayuki

I solved this issue by making a div around it and writing CSS for it as below React :-

   <div className="table-wrapper">
    <div className="table-scroll">
      <BootstrapTable
      keyField="id"
      data={data}
      columns={columns}
      >
    </div>
  </div>

CSS :-

 .table-wrapper {
  width: 100%;
  overflow-x: scroll;
}
.table-scroll {
  width: 200%;
}


PriyanshuPundhir avatar May 03 '23 09:05 PriyanshuPundhir