cancel
Showing results for 
Search instead for 
Did you mean: 

Different color of row

Former Member
0 Kudos

Hi experts,

I need to change the color the last row of my table with a different color. How can I do this?

TKS a lot in advance

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

HI,

For coloring your rows follow this approach :

1.Create a context attirbute for CELL_DESIGN of type WDUI_TABLE_CELL_DESIGN to the node to which the table is bound.

2. Bind this attribute to the CELL_DEISGN property of all the columns.

3. Get the no of rows in table.

4. When last row is selected, change the value of cell design attribue.

Sample Code :

lt_table - table with all data which is to be binded with table.

n - type I.

lv_tabix - type I.

ls_table - work area .

describe lt_table lines n.

loop at lt_table into ls_table . "This table is bound to node

lv_tabix = sy-tabix.

if lv_tabix = n.

ls_table-cell_design = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_DARK

modify lt_table from ls_table index lv_index.

ENDIF.

endloop.

Bind the table to the node.

For possible values for the color please check http://help.sap.com/saphelp_nw70/helpdata/en/45/0ef14d9d942462e10000000a1553f7/frameset.htm

This has been discussed many times :

Refer this thread :

Edited by: Saurav Mago on Oct 8, 2009 9:16 PM

Former Member
0 Kudos

Hi,

Sorry for the delay of response... You write:

"ls_table-cell_design"

but my table (this table is a standard table of a DB table) with the data that I bind don't have a column named "cell_design"... I don't understand...

Former Member
0 Kudos

If you dont have that attribute , please make the same and add it to the node which is binded to table :

Create a context attirbute for CELL_DESIGN of type WDUI_TABLE_CELL_DESIGN to the node to which the table is bound.

Former Member
0 Kudos

Hi,

1) First create a context attribute 'colour' with type " WDUI_TABLE_CELL_DESIGN" in our view controller.

2) Assign this colour attribute to cellDesign property of ur all table columns.

3)

 
      data: wd_node type ref to if_wd_context_node,
      lt_sflight type wd_this->elements_nd_sflight,
      wa_sflight type wd_this->element_nd_sflight.

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

*** Fetch the desired data from SFLIGHT

        select carrid
                  connid
                  fldate
                  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 = '09'.
    else.
      wa_sflight-colour = '07'.
    endif.
    modify lt_sflight from wa_sflight transporting colour.
  endloop.

  wd_node->bind_table( new_items = lt_sflight ).

Here in this example...if the price is >500 then it will display orange colour & if <500 it will display green colour.

thanks!

Edited by: sreelakshmi.B on Oct 14, 2009 10:43 AM