Showing results for 
Search instead for 
Did you mean: 

coloring a table.

Former Member
0 Kudos

hi all,

I am displaying a table in webdynpro.Based on the condition the rows of the table should be in different color.

Accepted Solutions (1)

Accepted Solutions (1)

Active Contributor
0 Kudos

Hi Siva,

Suppose I am displaying the data from SFLIGHT in a table & I want all the rows with PRICE > 500 in one colour and the rest in another then you can proceed as follows:

I have a context node by name SFLIGHT & it has CARRID, CONNID, FLDATE & PRICE as its attributes. In addition to these 4 dictionary fields I have a 5th attribute under the same node by name COLOUR. This is of type: WDUI_TABLE_CELL_DESIGN. I would be using this for changing the table's row colour. I dont hev any special settings for my context node.


Cardinality: 0..n
Selection: 0..1

I design a table in my layout & am displaying only the 4 dictionary fields in the table. (i.e, while doing the binding for the table I uncheck the checkbox for COLOUR so that it wouldnt get displayed.) Now I go to each column and bind its "cellDesign" property with the context attribute COLOUR. (i.e, MAIN.SFLIGHT.COLOUR)

So now as how you would have understood while populating my table with values I would just have to fill the context attribute COLOUR with the right value to reach the desired solution.

Answers (2)

Answers (2)

Active Contributor
0 Kudos

So thats it! Now upon execution your table would show all rows which have PRICE > 500 in 1 colour & the rest in another.

If you would like to check the possible list of values which you can assign then you can check the value range of the domain WDUI_TABLE_CELL_DESIGN which is associated with the type of the same name. (i.e, WDUI_TABLE_CELL_DESIGN).



Active Contributor
0 Kudos

Below is the coding from WDDOINIT that I use for populating the table & attribute COLOUR with data.

method WDDOINIT .
  data: wd_node type ref to if_wd_context_node,
        lt_sflight type wd_this->elements_sflight,
        wa_sflight type wd_this->element_sflight.

  wd_node = wd_context->get_child_node( name = 'SFLIGHT' ).

*** Fetch the desired data from SFLIGHT
  select carrid
         price from sflight into corresponding fields of table lt_sflight.
*** Am just trying to reduce the resultset so that it would be easier to see the output
  sort lt_sflight by price.
  delete adjacent duplicates from lt_sflight comparing price.

*** This is the main part. I loop through the data from SFLIGHT & check which rows have PRICE > 500
*** I assign different values to the COLOUR attribute when it is ( greater than 500 ) & ( less than or equal to 500 )
  loop at lt_sflight into wa_sflight.
    if wa_sflight-price > 500.
      wa_sflight-colour = '11'.
      wa_sflight-colour = '07'.
    modify lt_sflight from wa_sflight transporting colour.

  wd_node->bind_table( new_items = lt_sflight ).