cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Color of sap.m.Table Rows

stefan_heitzer
Participant
0 Kudos

Hi everybody,

I'm currently trying to change the background-color of a normal row inside a sap.m.Table.

I've already created a CSS which I added at the index.html.

The CSS contains the following class:


.day_background{

     background-color: red;

}

I have acutally a few XML-Views and in one there's a sap.m.Table.

When I try to add the style to the control it seems not to work.

The adding is done by the following code:


oTable.addStyleClass("day_background");

My guess is that the XML-Views have lost the reference for the CSS file?

Looking forward to your answers!

Greetings

Stef

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member189945
Contributor
0 Kudos

Hi Stefan,

Is there any error in console when you addStyleClass? E.g. is oTable undefined?

One possibility is to change default table/list cell style. You could do that with:

.sapMListTblCell {

                background-color: red;

            }

Regards,

Kimmo

stefan_heitzer
Participant
0 Kudos

Hi Kimmo,

thx for your quick reply!

No there is no error at all ...

Your possibility doesn't work for me because I'm only trying to set a specific background in some specific cases ...

Greetings

Stef

former_member189945
Contributor
0 Kudos

Maybe there is some other style overriding the background color. Try to add !important after the css style. That should make it show even if there are other styles.


.day_background{

  background-color: red !important;

}

If that doesn't work, then the style is somehow not applied or it is not visible because other elements completely hide the background. In that case, could you try to inspect the html with e.g. Chrome to see the styles applied.

Regards,

Kimmo

Message was edited by: Kimmo Jokinen