cancel
Showing results for 
Search instead for 
Did you mean: 

COLUMN COLOR

Former Member
0 Kudos

hi

i want to change color of cells background according to cells value in columns of ALV. how can i do this?

Can somebody help me please?

Thanks.

Accepted Solutions (0)

Answers (3)

Answers (3)

pranav_nagpal2
Contributor
0 Kudos

Hi Joshua,

Here is a simple blog which explains how to change the colors of cells and column depending on some condition...

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

regards

Pranav

Former Member
0 Kudos

Hi

i do

Loop at lt_gt_master2 into ls_gt_master2.

Loop at lt_columns into ls_column.

READ TABLE color_t

with KEY pernr = ls_gt_master2-pernr

lgart = ls_column-id+1(4)

INTO color_s.

IF sy-subrc = 0 .

lgid = ls_column-id.

lr_column1 = l_value->if_salv_wd_column_settings~get_column( lgid ).

lr_column1->SET_CELL_DESIGN_FIELDNAME( VALUE = 'ROWSTATE' ). "ROWSTATE VALUE 2

ELSE.

lgid = ls_column-id.

lr_column1 = l_value->if_salv_wd_column_settings~get_column( lgid ).

lr_column1->SET_CELL_DESIGN_FIELDNAME( VALUE = ''FREE" ). FREE VALUE NULL

"lr_column1->SET_CELL_DESIGN( '0' ).

ENDIF.

Endloop.

Endloop.

but all rows color affect that is to say [http://img262.imageshack.us/my.php?image=stateby4.jpg]

Thanks.

pranav_nagpal2
Contributor
0 Kudos

Hi Joshua,

See this wiki....[WIKI|https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/abapWebDynproALV-ChangeCellColourbasedonContent]

and see the attached file with this wiki it almost do the same thing you are looking for.........

regards

Pranav

Former Member
0 Kudos

Hi Joshua,

Follow this tips below and try doing accordingly.

1. In componenet controller create a method called some method say ( fill_data ).

*Here my node is table_alv and here depending upon the condition you can will the colors accrdingly

data lo_nd_table_alv type ref to if_wd_context_node.

data lo_el_table_alv type ref to if_wd_context_element.

data: ls_table_alv type wd_this->element_table_alv,

lt_table_alv type wd_this->elements_table_alv.

  • navigate from <CONTEXT> to <TABLE_ALV> via lead selection

lo_nd_table_alv = wd_context->get_child_node( name = wd_this->wdctx_table_alv ).

  • get element via lead selection

lo_el_table_alv = lo_nd_table_alv->get_element( ).

select *

from zse_project1 into corresponding fields of table lt_table_alv

where seprojcode = 'PJ292' or seprojcode = 'PJ356'.

loop at lt_table_alv into ls_table_alv.

ls_table_alv-celldesign = cl_wd_table_column=>e_cell_design-badvalue_light.

modify lt_table_alv from ls_table_alv transporting celldesign.

endloop.

*bind the table

lo_nd_table_alv->bind_table( lt_table_alv ).

call method lo_nd_table_alv->get_static_attributes_table

  • EXPORTING

  • from = 1

  • to = 2147483647

importing

table = lt_table_alv

.

step 2: Now go to the view where we have a table or the alv table in DOINIT method call the componenet controller method (fill_data ).

data lo_cmp_usage type ref to if_wd_component_usage.

lo_cmp_usage = wd_this->wd_cpuse_use_alv( ).

if lo_cmp_usage->has_active_component( ) is initial.

lo_cmp_usage->create_component( ).

endif.

*to get the table reference we call interface controller

data lo_interfacecontroller type ref to iwci_salv_wd_table .

lo_interfacecontroller = wd_this->wd_cpifc_use_alv( ).

*method get_model is used to get the reference of the table

data lo_value type ref to cl_salv_wd_config_table.

lo_value = lo_interfacecontroller->get_model(

).

Also refer to this links for clarification.

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814...

https://www.sdn.sap.com/irj/scn/wiki?path=/display/wdabap/how%252bto%252bedit%252bconditionally%252b...

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

Regards,

Sana.

Former Member
0 Kudos

hi

Thanks Your Answer,

i 'm to examine those link.

but i want to on this link.

[http://img262.imageshack.us/my.php?image=myalvhh9.jpg]

i'm use set_cell_design all row affect .

Former Member
0 Kudos

Hello Joshua,

i tried to change the bg-color of some columns like this:

data: lo_col_settings type ref to if_salv_wd_column_settings,

columns type salv_wd_t_column_ref,

wa_columns type salv_wd_s_column_ref.

columns = lo_col_settings->get_columns( ).

loop at columns into wa_columns.

if wa_columns-id = '[Name of the Coumn]'

wa_columns-r_column->set_cell_design( value = '08' ).

endif.

endloop.

its something i wrote after reading some random docs about this topic. I'm not sure about it, but it works. I do have some problems about using this "customized" ALV with custom themes, but the standerd thems work well with this code.

hope i could help you.