on 10-13-2011 10:50 AM
*how to assign colour to particular field.*
My code for editing paricular fields is as below. i want to assign color to the field lifnr
*****GET ALV CONFIGURATION SETTINGSUSING I/F CONTROLLERGET_MODEL
DATA: l_ref_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
l_ref_INTERFACECONTROLLER = wd_This->wd_CpIfc_Alv_Fr_Edit( ).
data:
l_VALUE type ref to Cl_Salv_Wd_Config_Table.
l_VALUE = l_ref_INTERFACECONTROLLER->Get_Model(
).
**************set entire alv as read only = false*****************
CALL METHOD L_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY
EXPORTING
VALUE = ABAP_false.
***************GET ALL COLUMNS OF ALV into an internaltable ****usethe method get_columns**of class *cl_salv_wd_config_table***
DATA : LT_COLUMNS TYPE SALV_WD_T_COLUMN_REF,"INTAB
LS_COLUMNS LIKE LINE OF LT_COLUMNS."WORKAREA
DATA : LT_COLUMNS TYPE SALV_WD_T_COLUMN_REF,"INTAB
LS_COLUMNS LIKE LINE OF LT_COLUMNS."WORKAREA
CALL METHOD L_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMNS
RECEIVING
VALUE = LT_COLUMNS
LOOP AT LT_COLUMNS INTO LS_COLUMNS ."FOR ALL FIELDS
if LS_COLUMNS-ID = 'LIFNR' OR LS_COLUMNS-ID = 'LAND1' . "FOR PARTICULAR FIELDS
CREATE OBJECT LR_INPUT
EXPORTING
VALUE_FIELDNAME = LS_COLUMNS-ID.
CALL METHOD LS_COLUMNS-R_COLUMN->SET_CELL_EDITOR
EXPORTING
VALUE = LR_INPUT
.
ENDIF.
ENDLOOP.
Moderator message: moved from ABAP General.
Edited by: Thomas Zloch on Oct 13, 2011 2:00 PM
Hi Dear,
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
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
3. To color a row:-
Proceed as above and set cell color for all the column.
Hope this will be helpful.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.