cancel
Showing results for 
Search instead for 
Did you mean: 

How to color each cell in different color in webdynpro table ?

Former Member
0 Kudos

Hi

i have a table in my webdynpro application which has 6 colums ( Sunday, Monday,...,Friday ),

each cell in this column can can containa one of the values X,Y,Z.

Is there a way to set the cell's color dynamicly so when the cell contains the valu X the cell will be in color green and if it contains the valu Y it will be in color red etc ?

i only fount the attribute CellDesign but it color the whole column and not a specific cell in the column.

Thanks

Ami

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Ami,

You can refer this document for your query:

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/707fb792-c181-2d10-61bd-ce15d58b5...

It will be helpful for you for sure

Regards,

Shahir Mirza

Answers (3)

Answers (3)

former_member186077
Active Participant
0 Kudos

Hi Ami,

Are you referring to calendar colors in CATS timesheet?

Thanks and Regards,

Sriranjani Chimakurthy.

0 Kudos

Hi Ami ,

To color a particular cell conditionally we need to follow the below steps :

1. First add  an extra column to the table of type WDUI_TABLE_CELL_DESIGN

2. Then fill values to this column while binding the alv table .

3. Then use method

wa_col-r_column->set_cell_design_fieldname to set the color .

4. Finally delete the extra column .

For example Code  :


METHOD onactiongo .

  DATA lo_nd_table TYPE REF TO if_wd_context_node.

  DATA : lt_table TYPE wd_this->elements_table,

         wa_table TYPE LINE OF wd_this->elements_table.

* navigate from <CONTEXT> to <TABLE> via lead selection

  lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).

  SELECT * FROM zapproval_cat INTO CORRESPONDING FIELDS OF TABLE lt_table .

  LOOP AT lt_table INTO wa_table.

    IF sy-tabix = 3.

      wa_table-cellcolour = '02'.

    ELSEIF sy-tabix = 5.

      wa_table-cellcolour = '03'.

    ENDIF .

    MODIFY lt_table FROM wa_table TRANSPORTING cellcolour .

  ENDLOOP .


  lo_nd_table->bind_table( new_items = lt_table set_initial_elements = abap_true ).

  DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

  lo_cmp_usage =   wd_this->wd_cpuse_zalv( ).

  IF lo_cmp_usage->has_active_component( ) IS INITIAL.

    lo_cmp_usage->create_component( ).

  ENDIF.

  DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .

  lo_interfacecontroller =   wd_this->wd_cpifc_zalv( ).

  DATA lv_value TYPE REF TO cl_salv_wd_config_table.

  lv_value = lo_interfacecontroller->get_model(

  ).

 

lv_value->if_salv_wd_table_settings~set_read_only( abap_false ). "This method enables all

*the std toolbar functions

     DATA : lr_col TYPE salv_wd_t_column_ref ,

         wa_col TYPE  salv_wd_s_column_ref .

  CALL METHOD lv_value->if_salv_wd_column_settings~get_columns

    RECEIVING

      value = lr_col.


  LOOP AT lr_col INTO wa_col .

    CALL METHOD wa_col-r_column->set_cell_design_fieldname

      EXPORTING

        value = 'CELLCOLOUR'.


  ENDLOOP .

  CALL METHOD lv_value->if_salv_wd_column_settings~delete_column

    EXPORTING

      id = 'READONLY'.

  CALL METHOD lv_value->if_salv_wd_column_settings~delete_column

    EXPORTING

      id = 'CELLCOLOUR'.

ENDMETHOD.

Thanks,

Suchi.

Former Member
0 Kudos

HI,

Thanks for your comment, but i am not talking about alv table.

Ami

Former Member
0 Kudos

Hi Ami ,

The technique is same for both ALV and normal table .

Thanks .

Former Member
0 Kudos

Hello Ami,

Good Morning

As per my knowledge either you can color whole column(full column) or whole row(1 single row).

still you can try with following  links.

http://help.sap.com/saphelp_nw2004s/helpdata/en/b5/ac884118aa1709e10000000a155106/frameset.htm

http://learnwdabap.blogspot.in/2011/06/changing-color-of-cell-in-alv.html

BR

Chandra..