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
}
[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.
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.
Please try what @andreykaipov suggested.
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
Thanks for this, maybe this should be somewhere in the documentation, had the exact same problem. Moving my component styles to the global styles solved the problem.
Any idea why I get "Cannot find name 'ViewEncapsulation'" when adding encapsulation: ViewEncapsulation.None? I'm new to ngx-datatable coding.
Hi @tonym99 ,
You have to import it first before using it
import { ViewEncapsulation } from '@angular/core';
Thanks!
Sent from my iPhone
On Nov 13, 2017, at 11:36 AM, Andrew Rutazamba notifications@github.com wrote:
Hi @tonym99 ,
You have to import it first before using itimport { ViewEncapsulation } from '';
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
I would use caution when dealing with ViewEncapsulation.
The setting of encapsulation: ViewEncapsulation.None will make it so that your component CSS is no longer restricted to confines of that component. i.e. It will essentially make your CSS global. This can lead to some very tricky CSS bugs and overuse negates the reason you are using a framework in the first place. Try to leverage CSS specificity as mentioned above.
Angular's default view encapsulation for components is
Emulatedto 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
:hostand/deep/selectors provided by Angular to style thengx-datatable, or just change your component's view encapsulation toViewEncapsulation.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.
Adding encapsulation: ViewEncapsulation.None did the trick!
I am not going to get back my 1 hour back - but that solved many of my problems such as
Thanks a lot!
Most helpful comment
Angular's default view encapsulation for components is
Emulatedto 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
:hostand/deep/selectors provided by Angular to style thengx-datatable, or just change your component's view encapsulation toViewEncapsulation.None. See https://angular.io/guide/component-styles for more details.You might have to be more specific with that selector though. Something like
should work after getting around the view encapsulation.