Ngx-datatable: Fixed Header

Created on 10 Jul 2017  路  7Comments  路  Source: swimlane/ngx-datatable

I need the grid to have the fixed header

Most helpful comment

.ngx-datatable {
  overflow: unset !important;
  datatable-header {
    overflow: unset !important;
    position: sticky;
    background: #fff;
    top: 0;
    z-index: 100;
    &:before {
      content: ' ';
      top: 0;
      left: 0;
      height: 100%;
      width: 100%;
      position: absolute;
      background: #fff;
    }
  }

All 7 comments

it will do that if you set the vertical scrolling as per some of the demos.
http://swimlane.github.io/ngx-datatable/#virtual-scroll

But you have to make sure your container for the table doesn't scroll otherwise you'll scroll the entire table out of the viewport, including the header.

I set an explicit size on ngx-datatable and datatable-body but various ways to do it as long as the scroll doesn't bubble to the container and scroll the table up out of view.

@dannyvenier - yup. thats how you do it. Thanks for helping out.

is it possible to create scroll with paging and table height should be fixed?

ngx-datatable has big issue of not using together [scrollbarV]=true and rowHeight="auto". When we use only rowHeight="auto" then header and footer not fixed.

@AshishBohara89 is this solved

I dont think @pptyasar that is solved. Also when I have fixed header there is no way to set it to auto and wrap text also doesn't work.

.ngx-datatable {
  overflow: unset !important;
  datatable-header {
    overflow: unset !important;
    position: sticky;
    background: #fff;
    top: 0;
    z-index: 100;
    &:before {
      content: ' ';
      top: 0;
      left: 0;
      height: 100%;
      width: 100%;
      position: absolute;
      background: #fff;
    }
  }
Was this page helpful?
0 / 5 - 0 ratings