cancel
Showing results for 
Search instead for 
Did you mean: 

Column visibility on a condition

Former Member
0 Kudos

Hello All,

I have requirment where in, I need to add columns to a Table

and this coloumns should appear on some condition bases.

Please let me know how to handle the visibility of column on certain condition.

Regards,

Neelima

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Solved

gill367
Active Contributor
0 Kudos

Hi

Are you talking about normal table or ALV

if it is ALV then you have to write some code in the init method to hide the column based on some condition

like the following code will delete the column status form ALV based on the condition.

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 lo_value TYPE ref to cl_salv_wd_config_table.
  lo_value = lo_interfacecontroller->get_model(
  ).
if "condition"
lo_value->IF_SALV_WD_COLUMN_SETTINGS~DELETE_COLUMN( 'STATUS' ).
endif.

and if it is normal table.

you can easily control it by defining an attribute of type wdUI_visibility and bind it to visiblity property of the column

and then based on the condition set the value of the attirbute.

Thanks

sarbjeet singh

vishesh_malik
Participant
0 Kudos

Hi Neelima,

You could write below mentioned code in WDDOMODIFY method of the view and here you can check your condition if condition is true then you can use '01' to make column invisible or '02' to make it visible.

IF condition .

Data lr_table_column TYPE REF TO CL_WD_TABLE_COLUMN.

lr_table_column ?= VIEW->GET_ELEMENT( 'ID_OF_TABLE_COLUMN' ).

CALL METHOD lr_table_column->SET_VISIBLE

EXPORTING

VALUE = '01' " use '01' to make column invisible and '02' to make it visible

.

ENDIF.

Regards,

Vishesh

Former Member
0 Kudos

setting the visibility - a suggestion is to use the constants from the respective class.

CL_WD_TABLE_COLUMN=>e_visible-visible or

CL_WD_TABLE_COLUMN=>e_visible-none

Former Member
0 Kudos

Thanks all

Former Member
0 Kudos

Hello Neelima,

You could add a new table column using CL_WD_TABLE_COLUMN class and NEW_TABLE_COLUMN method.

I would suggest you that if you know at design time maximum how many columns do you need, you could define all at design time and make them invisible by default and when required at runtime, change the attribute value which is bind to the visibilty of the column.

it would help in performance.

Former Member
0 Kudos

Hello Neelima,

You would need an attribute of type wdy_boolean and bind it to the visible proprty of the particular table column.

and then change the value of that column based on your condition.

Regards

Anurag Chopra