on 01-15-2009 12:07 PM
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.
Hi Joshua,
Here is a simple blog which explains how to change the colors of cells and column depending on some condition...
regards
Pranav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
Regards,
Sana.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
92 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.