on 07-19-2016 5:42 AM
Hi ,
I have a requirement where in i need to color a column in alv webdynpro. I have written a code but in that the cell which is getting coloured is the second row and not the first row which I actually want.Kindly suggest.
Try this kind of code in WDDOINIT method of VIEW.
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_alv( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
DATA lv_value TYPE REF TO cl_salv_wd_config_table.
lv_value = lo_interfacecontroller->get_model(
).
data lr_column type ref to cl_salv_wd_column.
CALL METHOD lv_value->if_salv_wd_column_settings~get_column
EXPORTING
id = 'VBELN'
receiving
value = lr_column.
.
call method lr_column->set_cell_design
exporting
value = 1.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Pranav,
am able to achieve the functionality for getting a single cell highlighted/coloured. The issue I am facing here is, say, there are two rows in my ALV table. I want my cell under VBELN and first row only, to get coloured. What I am getting currently is cell under VBELN is coloured but for the second row which is not desired. Let me know if you have any solution for this.
thanks!
Hi Vasvi,
First you need to modify the context node output table to add an attribute -- say 'CELL_COLOR' of type 'WDY_UIE_LIBRARY_ENUM_TYPE' .
Then try below code.
DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_alv( ).
IF lo_cmp_usage->has_active_component( ) IS INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
DATA lo_interfacecontroller TYPE REF TO iwci_salv_wd_table .
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
DATA lv_value TYPE REF TO cl_salv_wd_config_table.
lv_value = lo_interfacecontroller->get_model(
).
data ls_column type SALV_WD_s_COLUMN_REF.
data lt_column TYPE SALV_WD_T_COLUMN_REF.
DATA: l_column_header TYPE REF TO cl_salv_wd_column_header .
CALL METHOD lv_value->if_salv_wd_column_settings~get_columns
RECEIVING
value = lt_column
.
DATA :lo_column TYPE REF TO cl_salv_wd_column . .
LOOP AT lt_column INTO ls_column .
lo_column = ls_column-r_column. .
CASE ls_column-id .
WHEN 'VBELN' .
l_column_header = lo_column->get_header( ) .
l_column_header->set_ddic_binding_field(
if_salv_wd_c_column_settings=>ddic_bind_none ) .
ls_column-r_column->set_cell_design_fieldname( value = 'CELL_COLOR' ). "binding C1 is attribute
WHEN 'CELL_COLOR'.
CALL METHOD lo_column->set_visible(
EXPORTING
value = '00'
).
ENDCASE.
ENDLOOP.
DATA lo_nd_vbak TYPE REF TO if_wd_context_node.
DATA lt_vbak TYPE wd_this->elements_vbak.
DATA ls_vbak TYPE wd_this->element_vbak.
* navigate from <CONTEXT> to <VBAK> via lead selection
lo_nd_vbak = wd_context->get_child_node( name = wd_this->wdctx_vbak ).
lo_nd_vbak->get_static_attributes_table( IMPORTING table = lt_vbak ).
LOOP AT lt_vbak INTO ls_vbak.
IF ls_vbak-vbeln = 8003892.
ls_vbak-cell_color = '03'.
ENDIF.
MODIFY lt_vbak from ls_vbak INDEX sy-tabix.
ENDLOOP.
lo_nd_vbak->bind_table( new_items = lt_vbak set_initial_elements = abap_true ).
Output:
Hi Pranav,
Finally I was working again on this issues and the problem seems to be strange. I am getting the columns coloured but not for the first row. That is, I have a requirement where in I need to display two rows and need to colour both the cells of both the rows. But, every time my second row displays as desired but first row comes with any coloured cell. I have attached the screen shot. Here, you can see I have two rows one with R and another with L. I want both the R and L cells to be coloured and not just the L one.
Hi I have got the solution. In addition to the code suggested above we need to write 2 more lines of code:
wd_this->alv_config_table->if_salv_wd_table_settings~set_row_selectable( value = abap_false ).
wd_this->alv_config_table->if_salv_wd_table_settings~set_selection_mode( cl_wd_table=>e_selection_mode-single ).
where, type of alv_config_table is cl_salv_wd_config_table
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.