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.

Cannot apply styles to the rows

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

Current behavior Datatable uses ViewEncapsulation.None, so I can apply styles to it. But body-row.component uses default encapsulation, and styles are ignored.

Say, I can change background color of the table: .ngx-datatable.material { background: #444; } but not rows: .datatable-body-row { background: #665; } <- no effect

Expected behavior

I’d like to style rows in my app instead of modifying css styles in ngx-datatable release folder. Note that even moving material.css from its location to my app folder is not going to wok.

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Styling the grid, applying my own ‘selected’ color.

Please tell us about your environment:

VS Code, webpack-server.

  • Table version: 0.7.x

I checked sources, and they still use encapsulation, so yes.

  • Angular version: 2.0.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Chrome.

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

11reactions
mikekovcommented, Mar 7, 2017

Thanks for reference. In case somebody is reading this…

To change grid style I put them in the app global css. For instance to change the header:

.datatable-header {
   color: $text-color;
   background-color: $active-background-color;
}

To modify rows:

.datatable-body-row {
   color: $dim-text-color;
   border-bottom: 1px solid $active-background-color;
   &:hover {
      background-color: $app-dim-selection-color;
   }
   &.active {
      color: $text-color;
      background-color: $app-selection-color;
   }
}

To change rows dynamically add [rowClass]=“getRowClass” to your ngx-datatable and define getRowClass function:

getRowClass(row) {
   return { 'important-row': <condition>, ... <more classes as needed> };
}

8reactions
joshua-foggcommented, Feb 1, 2018

If the above don’t fix the issue then also try prefixing ::ng-deep onto your css selectors ie: ::ng-deep .age-is-ten{ background : pink; height: 1000px; } allows getRowClass(row) { return { 'age-is-ten': row.procedureActionableProcedureID === "A100", } } to target child and nested components / containers

Read more comments on GitHub >

github_iconTop Results From Across the Web

I cannot apply CSS in html table - Stack Overflow
I cannot apply the CSS in the table. For example I want the table to be displayed in the middle and to change...
Read more >
Apply, create, or remove a cell style - Microsoft Support
Click Format. On the various tabs in the Format Cells dialog box, select the formatting that you want, and then click OK. In...
Read more >
Format an Excel table - Microsoft Support
Format an Excel table by applying different table styles or colors. ... by choosing Quick Styles options for table elements, such as Header...
Read more >
Video: Apply a table style - Microsoft Support
To alternate row or column colors and make tables easier to read, select Design > Banded Rows or Design > Banded Columns. Repeat...
Read more >
React Data Grid: Row Styles - AG Grid
Row Class Rules: Providing rules for applying CSS classes. ... The grid cannot depend on using CSS :hover selector as this will not...
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