cancel
Showing results for 
Search instead for 
Did you mean: 

Smartforms - Colouring a table cell depending on contents

Former Member
0 Kudos

Hi,

I have a smartform table and I want to change the background colour of one cell depending on the contents of each line.

For example, in my internal table I have the following records:

Yellow

Red

Green

In my smartform I have a table which loops at my internal table. I want the 'Yellow' line to have the background colour of yellow, the 'Red' line to have a background colour of red etc.

I've looked in my smartstyle sheet to see if I could create a paragraph format or character format with the different colours as backgrounds but I can only change the text colour using those.

I've created different line types with the cell coloured in, but can't insert an IF command before the table line in the 'Main Area' of the table. I can insert an IF command inside the line cell but that doesn't help me as I need to create a different line using the line type with the correct colour.

Can anyone see a solution to this?

Thanks,

Gill

Accepted Solutions (1)

Accepted Solutions (1)

naimesh_patel
Active Contributor
0 Kudos

You can try with Creating Three line types: One with Yellow, one with Red and One with Green.

Ana depends on the condition you can call the suitable line.

I have tried to remove / change entire background color.

Here you can look at my WIKI https://wiki.sdn.sap.com/wiki/display/Snippets/DynamicBackgroundColorsinSmartForms

Regards,

Naimesh Patel

Former Member
0 Kudos

I have created 3 line types.

My problem is where do I determine which line type to use. I can't insert any IF command before the line in the 'Main Area' section of my table.

Former Member
0 Kudos

Put the condition in the 'Condition tab' of the Rows you create from the linetypes

Former Member
0 Kudos

Genius!

So simple, yet it works!

Thanks.

naimesh_patel
Active Contributor
0 Kudos

You can use the Condition tab of the Line type to know which line you have to use.

Take a flag field in the internal table. (ITAB-FLAG)

Before coming to the TABLE node, fill the flag as per the requirement to show yellow, red or green.

ITAB-FLAG = 1 " Green

ITAB-FLAG = 2 " Yellow

ITAB-FLAG = 3 " Red

Use that field in the condition tab.

For Green line:

ITAB-FLAG EQ 1

and so on.

Regards,

Naimesh Patel

Answers (0)