cancel
Showing results for 
Search instead for 
Did you mean: 

controlling visibility of ALV columns at runtime

Former Member
0 Kudos

Hi

I have an ALV column which is of type DropdownByKey. I can control the visibility of the dropdown by setting it based on another context node attribute (for e.g., 'CAT_VALUE_I_VISIBLE') which I modify at runtime. But then I want to hide the column itself based on the other context node attribute which I am not able to. Is it possible ?

I have something like this to hide the dropdown

lo_drdn_by_key->set_visible_fieldname( 'CAT_VALUE_I_VISIBLE' ).

But on the column level there is only a method like :

DATA lo_column type ref to cl_salv_wd_column.

lo_column-r_column->set_visible( cl_wd_uielement=>e_visible-none ).

Is there a possibility to control the visibility of an ALV column at runtime ?

Thanks and regards

Sukanya

Accepted Solutions (0)

Answers (2)

Answers (2)

arjun_thakur
Active Contributor
0 Kudos

Hi,

You can use this code to hide the column of the alv table:



  data l_salv_wd_table type ref to iwci_salv_wd_table.
  l_salv_wd_table = wd_this->wd_cpifc_alv_first( ).
  data l_table type ref to cl_salv_wd_config_table.
  l_table = l_salv_wd_table->get_model( ).
  data l_column type ref to cl_salv_wd_column.


l_column = l_table->if_salv_wd_column_settings~get_column( 'CARRID' ).
l_column->SET_VISIBLE( IF_WDL_CORE=>VISIBILITY_BLANK ).

I hope it helps.

Regards

Arjun

former_member262988
Active Contributor
0 Kudos

Hi,

Depending upon another context attribute condition get th ecolumn ref of the alv field which you want to hide and set the visibility property to none.

data : lt_columns type SALV_WD_T_COLUMN_REF.

  • Get the column ref

CALL METHOD lo_value->if_salv_wd_column_settings~get_columns

RECEIVING

value = lt_columns.

CALL METHOD lr_column->set_visible

EXPORTING

value = cl_wd_uielement=>e_visible-none.

Thanks,

Shailaja Ainala.