Opening bootstrap select in bootstrap table issue
Asked Answered
M

3

7

The Problem

I am using the bootstrap-table plugin and the bootstrap-select plugin, which both work very nice.
But I get an issue when I use the bootstrap-select inside a bootstrap-table. If the select box of the last row opens, the table size changes instead of the selectbox going "over" the table area creating a scroll area which I do not like.

Like in the image below: enter image description here

I have tried to "fix" this effect using the below javascript code, but to no avail. The code gets executed but the problem is still there. I do not see which css is responsible for this behaviour and any help is highly appreciated.

$('.table-responsive').on('show.bs.select', function () { 
  console.log("triggered show bs select");
  $('.table-responsive').css( "overflow", "hidden" ); 
}); 
$('.table-responsive').on('hide.bs.select', function () { 
  console.log("triggered hide bs select");
  $('.table-responsive').css( "overflow", "auto" ); 
})

Example

The behaviour can be seen in:
Jsfiddle:http://jsfiddle.net/e3nk137y/8612/


Edit

I have it working now but only with applying padding-bottom on the table and using the following js code:

$('.table-responsive').on('show.bs.select', function () { 
      $('.table-responsive').css( "overflow", "inherit" );
      $('.bootstrap-table').css( "overflow", "inherit" ); 
      $('.fixed-table-body').css( "overflow", "inherit" );     
 }); 

I leave the question open for now since this is not a "nice" fix in my oppinion, especially the added padding which is needed to "hide" the select box again.

Mammillate answered 19/9, 2016 at 10:13 Comment(0)
P
15

You can add the option container: 'body'. This will place the drop-down outside the table and will prevent the issue. If there's a problem with body, just use any element that contains the table, which is large enough to contain the drop-down menu.

Jsfiddle

Prophecy answered 19/9, 2016 at 13:26 Comment(2)
use it like <select data-container="body" ..... other options> </select>Liebermann
That is real answerViva
C
2

The class .fixed-table-body seems to be causing this. Removing overflow-x: auto; and overflow-x: auto; fixes your issue.

Cho answered 19/9, 2016 at 10:27 Comment(1)
Thank you, it is indeed those but a bit more in my case was needed to make it work completely. If no better / nicer solution shows up I will accept this as answer.Mammillate
I
0

The class .table-responsive seems to be causing this. Removing overflow-x: auto; fixes your issue. You can find the style in bootstrap.css

Italianize answered 22/12, 2017 at 6:21 Comment(1)
Comments should not be in answer sectionMummify

© 2022 - 2024 — McMap. All rights reserved.