How do I dynamically color cells in a table ?

How do I dynamically color cells in a table ?

  

Hi


I want to color my tables with either green or orange depending on some variable. how do i color them in a table's cell ?

Hi Gontse,


Check the extended properties of your cell (or table if you want to color the complete table).

You can set extended properties like "class" or "style" and control the color of the cells with them.


Regards,

João Rosado

Eish im really not understanding you.. can you give me an example ?

Solution

Hi!

Expanding what João said, what you have to do, is in each cell you want to have a dynamic background colour, go to the cell's extended properties:

choose the Style in the Property dropdown, and then add an expression to the Value. This expression will look something like If([condition], "background-color: [a colour]", "background-color: [another colour]").

Hope this helps!


Solution

Pheeew. got it right.. thank you. I was on a deadline.

Carlos Ribeiro da Fonseca wrote:

Hi!

Expanding what João said, what you have to do, is in each cell you want to have a dynamic background colour, go to the cell's extended properties:

choose the Style in the Property dropdown, and then add an expression to the Value. This expression will look something like If([condition], "background-color: [a colour]", "background-color: [another colour]").

Hope this helps!


I had a similar problem which I have half sorted out by your method but I want to do multiple if's but in Outsystems we can just do only one If I beleive like below

If(ContactForm.Record.Contact.Color = "Black","background-color:"+ContactForm.Record.Contact.Color+";color,"background-color:"+ContactForm.Record.Contact.Color)

but I need to set color and text as well along on the Style property, basically:
if color="Black" {
"background-color:"+ContactForm.Record.Contact.Color+"text:Obsolete"
}

do you know if something like this is available or I'm hitting a wall here.

Cheers,
Sandeep Kapil.

all good I have sorted myself with the nested if's :-). working like a charm. Have a look at below, it might help someone else:

SyntaxEditor Code Snippet

If(ContactForm.Record.Contact.RoadMap = "Current","background-color:Lightgreen;",If(ContactForm.Record.Contact.RoadMap = "Retire","background-color:pink;",
If(ContactForm.Record.Contact.RoadMap = "TBC","background-color:White;","background-color:LightYellow;")))