question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fixed columns not working properly when there's nothing to scroll

See original GitHub issue

Bootstrap-Table version: v1.15.5 Browsers: Chrome and Firefox

I’m using Bootstrap-Table with Bootstrap 4. My html composition is like this:

<div id="content-main">
   <div class="container" id="accordion">
            <div class="row">
                <div class="col-12"><table id="table" class="table order-list table-striped"></table>               
                </div>
            </div>
    </div>
</div>

In JS I initialize the table and I pull data from an API endpoint. I use a responseHandler to insert give that data the form that I need to show in the table. I have this:

$table = $('#table').bootstrapTable({
      method: 'get',
      url: '/api/endpoint/',
      responseHandler: 'responseHandler',
      classes: 'table table-hover',
      theadClasses: 'thead-dark header',
  });

When I process the new columns, I do this: (Note that columns is a global variable in which I define my static structure of columns. Also, I set the responseHandler back because I had to call addColumns from my first responseHandler and that created an infinite loop).

function addColumns(values) {
  var new_column_header = {
    title: 'TEST',
    colspan: values.length
  };

  columns[0].push(new_column_header);
  for (value in values) {
      var new_column_value = {
        title: values[value][0],
        field: 'value_' + values[value][0],
        align: 'center',
      }
    }
    columns[1].push(new_column_value);
  }

  $table.bootstrapTable('refreshOptions', {
    columns: columns,
    fixedColumns: true,
    fixedNumber: 9,
    responseHandler: function (res) {
      return res;
    }
  });
}

Everything works fine. My table has 9 columns that are always there and I fix using the plug-in and then a few columns that I append dynamically. If the current browser size is wide enough so that all the table fits in, I get this weird interaction. Pasted Graphic

If I make the browser window small enough that I can scroll at least a little bit, everything shows right. Screenshot 2019-10-24 at 17 14 44

Please note that if I load the page with the window being maximized and then try to make it smaller, it will not work. It will stay like in the first picture.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
vinnesccommented, Nov 2, 2019

@UtechtDustin Sure. I changed this https://github.com/wenzhixin/bootstrap-table/blob/ab5ebe10cbc5b0716c78091f872d505779484459/src/extensions/fixed-columns/bootstrap-table-fixed-columns.js#L60 to:

this.$fixedBody.css({
      top: 0,
      width: '100%',
      height: this.$tableHeader.outerHeight(true) + this.$tableBody.outerHeight(true)
      clip: 'rect(0px,' + this.getFixedColumnsWidth() + 'px, auto, auto)'
    })

I’m going a little bit by memory but yeah, that’s it. Would be cool if we could test this example with that change https://live.bootstrap-table.com/code/rparnas/399.

1reaction
vinnesccommented, Oct 25, 2019

Update: Might’ve solved it changing the CSS rules that the extension generates for the fixed-columns-body. Will do some more testing through the day and hopefully post a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to use fixedColumn but for somereason it wont work at all.
Thanks extreme allan. Using 2.0.3 fixed the scrolling issue its now only on the right side. However columns are still completely miss aligned....
Read more >
fixed column not working - Stack Overflow
Datatable Fixed column is not working. Scrollbody width and table widths are coming as equal. So I am not getting the horizontal scroll...
Read more >
Can't Scroll in Excel? Here Are Reasons and Easy Fixes!
You cannot scroll in Excel? Here are four different potential reasons and simple solutions! Try these and you will be able to scroll...
Read more >
Freeze panes to lock rows and columns - Microsoft Support
Select the cell below the rows and to the right of the columns you want to keep visible when you scroll. · Select...
Read more >
Freeze or Lock Specific Rows and Columns when Scrolling in ...
Unfreeze/Unlock Columns and Rows in Excel ... Go to the View tab and click Freeze Panes and, if there are any frozen panes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found