cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically disable/enable columns of a table

thomas_mueller8
Participant
0 Kudos

Hi Gyus,

I'm struggling with a WD problem. I want to dynamically disable/enable columns of a table but I'm not sure how to do this.

I have a view which contains a UI table object and a DDic control table to indicate which columns should be displayed in my view.

The UI table structure looks as follows:

TABLE (TABLE)

- TC_1 (TableColumn

- TE_1 (TextView)

- TH_1 (Caption)

- TC_2

- TE_2

- TH_2

- TC_3

- TE_3

- TH_3

- TC_4

- TE_4

- TH_4

Let's say, I want to disable column TC_2. What would be the correct coding in method WDDOMODIFYVIEW to do this?

Any hint would be helpful. Thanks.

Thomas

Accepted Solutions (0)

Answers (3)

Answers (3)

bhargavab4
Explorer
0 Kudos

Hi thomas,

try to get the UI element and disable the required clolumn ,

if the coloumn TC_2 is input field below method will work

DATA LO_COL TYPE REF TO cl_wd_input_field.

lo_col ?= view->get_element('TC_2').

CALL METHOD LO_COL->SET_ENABLED

EXPORTING

VALUE = ''

.

Bhargava

Former Member
0 Kudos

hi thomos,

when you want disable your column?

Create one attribute of type WDY_BOOLEAN and bind this table column of Readonly property.

Set this value using set_attribute whenever you want to disable the cell by passing ABAP_FALSE.

Cheers,

Kris.

former_member199125
Active Contributor
0 Kudos

If you are talking about ALV table then below is the method..

  • Create component usage for alv component

DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).

IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

l_ref_cmp_usage->create_component( ).

ENDIF.

  • Get config model

DATA: l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table .

l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).

DATA: l_value TYPE REF TO cl_salv_wd_config_table.

l_value = l_ref_interfacecontroller->get_model( ).

DATA: lr_column TYPE REF TO cl_salv_wd_column.

lr_column = l_value->if_salv_wd_column_settings~get_column( 'column attribute name in capital letter'' ).

DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,

lr_column_settings ?= l_value.

lr_column_settings ->set_read_only( abap_true ).

Regards

Srinivas

thomas_mueller8
Participant
0 Kudos

Hi Sanasrinivas,

I'm not sure if this is an ALV table. To me it looks as a normal table to me. -> How can I recognize if this is an ALV table?

What would be the difference between an ALV table and a normal table?

Kind regards,

Thomas

former_member199125
Active Contributor
0 Kudos

HI thomas,

Sorry initially i din't observe your query. your table is normal table, i can say by reading your table properties.

FYI if it is alv table , in output you will find "export to excel " button in table status bar.

So follow the kris solution, and I think you are very new to webdynpro.

Regards

Srinivas