cancel
Showing results for 
Search instead for 
Did you mean: 

Color some Cells in WD ALV

Former Member
0 Kudos

Hello,

im trying to Color some Cells in a Webdynpro ALV.

So far i found out that there are maybe two ways:

one like this with WDUI_TABLE_CELL_DESIGN

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b7...

but i didnt find out, how to color specified Cells. With this example it is only possible to color the column by the saved color.

the other way is to append a color table to ich column LVC_T_SCOL

and after that


*   We will set this COLOR table field name of the internal table to
*   COLUMNS tab reference for the specific colors    
TRY.        
lo_cols_tab->set_color_column( 'T_COLOR' ).      
CATCH cx_salv_data_error.                         "#EC NO_HANDLER    
ENDTRY.

http://help-abap.blogspot.com/2008/10/salv-table-9-apply-colors.html

but i dont works in Webdynpro ALV. or has someone an idea?

i hope someone can help me.

greets,

Sascha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check out this link

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abapWebDynproALV-ChangeCellColourbasedonContent

Regards,

Lekha

Former Member
0 Kudos

Hi,

its very near but the problem is, i have to work with a colortable

because die itab looks like this

workgroup | skill | pt1 | pt2 | pt3 | pt4 | pt5|

and for example: if pt1 has the cheapest price, cell pt1 ind line 1 hast to be colored green.

or if pt1 and pt2 and pt5 are cheapest and have the same amount. they all have to be colored green.

the nearest solution i found was the one with de colortable type LVC_T_SCOL, but it dont works with WD ALV maybe i didnt found the right way.

Former Member
0 Kudos

Hello all,

I created an ALV report in which I have assigned a color to some cells.

The problem is that when I want to sort a column, all the colors disappear.

Do you know how to keep the assignment of the colors to the cells after a sorting?

Thank your for your help.

Regards,

Former Member
0 Kudos

Hi ,

Check this thread, [https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71393]

In your case you will have to create 1 attribute ( type WDY_UIE_LIBRARY_ENUM_TYPE ) for every column. ( for eg: c1, c2, c3 ,c4 , c5 for pt1 pt2 pt3 pt4 pt5 respectively ) and bind it as follows,

*---------- Column settings
  DATA: l_column_settings TYPE REF TO if_salv_wd_column_settings.
  l_column_settings ?= lo_value.

* Get columns
  DATA: lt_columns TYPE salv_wd_t_column_ref ,
        ls_columns TYPE salv_wd_s_column_ref .

  DATA: l_column_header  TYPE REF TO cl_salv_wd_column_header .

  lt_columns = l_column_settings->get_columns( )              .

  LOOP AT lt_columns INTO ls_columns                          .
    CASE ls_columns-id                                        .
      WHEN 'PT1'                                            .
        l_column_header = ls_columns-r_column->get_header( )  .
        l_column_header->set_ddic_binding_field(
           if_salv_wd_c_column_settings=>ddic_bind_none )     .
        ls_columns-r_column->set_cell_design_fieldname( value = 'C1' ). "binding C1 is attribute 

      WHEN 'PT2'                                            .
        l_column_header = ls_columns-r_column->get_header( )  .
        l_column_header->set_ddic_binding_field(
           if_salv_wd_c_column_settings=>ddic_bind_none )     .
        l_column_header->set_text( 'Item No' )                .
        ls_columns-r_column->set_cell_design_fieldname( value = 'C2' ). " binding
       ........similarly continue for all the columns.

Now modify your internal table based on your condition and set the required color as follows,

  LOOP AT lt_alv INTO ls_alv.
          if pt1 is lowest.  
            ls_alv-color1 = '02'. " green
          elseif pt2 is lowest.
            ls_alv-color2 = '03'.  "red
          endif.
          MODIFY lt_alv FROM ls_alv INDEX sy-tabix.
        ENDLOOP.

* Bind Data to ALV
        cn_alv->bind_table( lt_alv ).

Hope it helps!

Radhika.

Former Member
0 Kudos

GREAT!!

thanks. Problem Solved!

Former Member
0 Kudos

Hi Radhika,

I already checked this thread and this is the one I used to build my Web Dynpro ALV.

I can manage cells colors, and it works fine, but when I sort the columns, all the colors disappear.

I have done what you mention but it doesn't work...

Former Member
0 Kudos

try

SORT itab STABLE BY comp.

Former Member
0 Kudos

Hi sascha,

When I say that the colors disappear after column sorting, i talk about the sorting standard functionality in the alv.

When I click on the column I want to sort, the colors disappear.

This is not a "coded" sort.

Former Member
0 Kudos

nobody can help?

Answers (0)