on 04-07-2011 10:22 AM
Hi Friends,
can someone tell me how to color column and row of ALV table. Based on conditions i should change color.
Regards
Anand
HI webdynpro32,
1. To color a column:-
use the method set_cell_design in class CL_SALV_ WD_COLUMN and there u provide the details of the alv column.
Check:-
[Column coloring in ALV|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/006c7f3a-c181-2d10-d6af-c4cbbcfeb5c8]
To color a particular cell:-
Add one attirbute cell_color in your context node . And based on some condition you set set the value of the color in it.
like :-
IF
(CONTEXT_NODE-ATTRIBUTE1) > 30.
CONTEXT_NODE-CELL_COLOUR = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-GOODVALUE_LIGHT.
ELSEIF (CONTEXT_NODE-ATTRIBUTE1)< 10.
CONTEXT_NODE-CELL_COLOUR = CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_LIGHT.
Now afetr instantiating your alv and using get_model method of it set this attribute for the particular column. As you need to get row identity and column identity to adentify a particular cell. So get the column reference and give the value 'CELL_COLOUR' in the SET_CELL_DESIGN_FIELDNAME.
like:-
LOOP AT LT_COLUMNS INTO LS_COLUMN .
CASE LS_COLUMN-ID .
WHEN 'column_name'.
CREATE OBJECT LR_INPUT_FIELD
EXPORTING
VALUE_FIELDNAME = LS_COLUMN-ID.
LR_COLUMN = LV_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( ID = LS_COLUMN-ID ).
LR_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).
LR_COLUMN->SET_CELL_DESIGN_FIELDNAME( VALUE = 'CELL_COLOUR' ).
ENDCASE.
ENDLOOP.
Check:-
[Conditionally Assigning Colors and Input Enable to ALV Columns in Web Dynpro ABAP|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/f0625002-596c-2b10-46af-91cb31b71393]
3. To color a row:-
Proceed as above and set cell color for all the column.
Hope this will be helpful.
Regarding,
Monishankar C
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
CALL METHOD LR_COLUMN->SET_CELL_DESIGN_FIELDNAME
EXPORTING
VALUE = 'CELL_COLOR'.
Context attribute 'CELL_COLOR' contains the color information and then bound it to column.
Please go through this...
https://wiki.sdn.sap.com/wiki/display/Snippets/ABAPWebDynproALV-ChangeCellColourbasedonContent
Cheers,
Kris.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
add an extra attribute in the node which is binded to the ALV ( Color type string )
lr_cmp_usage = wd_this->wd_cpuse_alv( ).
if lr_cmp_usage->has_active_component( ) is initial.
lr_cmp_usage->create_component( ).
endif.
lr_model = lr_intf_ctrl->get_model( ).
lr_column = lr_model->if_salv_wd_column_settings~get_column( <column attribute name' ).
lr_column->SET_CELL_DESIGN_FIELDNAME( '<New attribute created>' ).
while filling the table entries set the value for this new attribute from the following possible list
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-STANDARD
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-NEGATIVE
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-POSITIVE
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_DARK
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_MEDIUM
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-BADVALUE_LIGHT
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-CRITICALVALUE_DARK
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-CRITICALVALUE_MEDIUM
CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-CRITICALVALUE_LIGHT
Abhi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.