0

I have give rowStyle based on condition. This datatable also has selection (check-box) option.

rowStyleClass="#{condt ? myStyle : null}"

I would like to retain the custom style that is applied on the row, even when it is selected (i.e., check-box is checked). By default, when the row is selected it is highlighted in yellow irrespective of the style applied.

CSS:

 .ui-datatable .ui-state-highlight {
        background-image: none;
        background-color: yellow !important;
    }
    .myStyle  {
        background-image: none;
        background-color: red !important;
    }

Can I retain the rowStyle already applied even when check-box is selected.

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Teela
  • 153
  • 1
  • 3
  • 9
  • 1
    Possible duplicate of [How do I override default PrimeFaces CSS with custom styles?](https://stackoverflow.com/questions/8768317/how-do-i-override-default-primefaces-css-with-custom-styles) – Jasper de Vries Feb 12 '19 at 15:52

1 Answers1

0

To retain the custom color when row(the check-box) is selected, I used below CSS

.ui-datatable .ui-state-highlight.myStyle {
            background-image: none;
            background-color: red !important;
        }

By doing so, the selected row that had no style applied will be highlighted in yellow, however if the row which has custom style applied is selected, then only the check-box will be checked and the highlight color of the row will not change to yellow.

Teela
  • 153
  • 1
  • 3
  • 9