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.

I am unable to set Header cell style for ngx-datatable

See original GitHub issue

I’m submitting a … (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

unable to set Header style for ngx-datatable .datatable-header-cell{ color :green }

HTML

<ngx-datatable id =“ngxdatatable” class=‘material’

      [rows]="rows" 
      [rowHeight]="20"
      [columns]="columns" 
      [columnMode]="'force'" 
      [scrollbarV]="true"
      [scrollbarH]="true"
      [headerHeight]="30"
      [footerHeight]="50"
      [limit]="35"
      (page)="onPage($event)">
              
    </ngx-datatable>

but still style is not applied, data table still showing with default style color.

Please Help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

27reactions
andreykaipovcommented, Jun 22, 2017

Angular’s default view encapsulation for components is Emulated to mimic a shadow DOM behavior effectively scoping a component’s CSS within that component only.

To get around this, you could place that CSS into your global styles. Alternatively, you can use the :host and /deep/ selectors provided by Angular to style the ngx-datatable, or just change your component’s view encapsulation to ViewEncapsulation.None. See https://angular.io/guide/component-styles for more details.

You might have to be more specific with that selector though. Something like

.ngx-datatable.material {
  .datatable-header {
    .datatable-header-cell {
      // your styles here
    }
  }
}

should work after getting around the view encapsulation.

19reactions
dev2jscommented, Oct 6, 2017

I had a problem adding styles to the table. I added below in my component @Component({ … encapsulation: ViewEncapsulation.None, }) this takes my custom styling files

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix header in ngx-datatable - Stack Overflow
I need to have a table with fixed header and scroll-able content. Below is the code : <ngx-datatable [rows]="qrCodes" class="material qr ...
Read more >
swimlane/ngx-datatable - Gitter
Hi all, I modified the style for the datatable-body-cell-label , which applies to the element holding the text inside a cell, to allow...
Read more >
swimlane/ngx-datatable - npm
Handle large data sets ( Virtual DOM ) · Expressive Header and Cell Templates · Horizontal & Vertical Scrolling · Column Reordering &...
Read more >
Creating an Ionic Table With ngx-datatable - Devdactic
If you are working with a lot of data you might have encountered the problem of presenting this data in an Excel like...
Read more >
Themeing - ngx-datatable - GitBook
Out of the box, the data-table is not styled. · There is a separate material theme distributed with data-table. · This is a...
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