cancel
Showing results for 
Search instead for 
Did you mean: 

Disable Table (Not ALV) Column dynamically

Former Member
0 Kudos

Hi,

I have found several posts/solution on how to disable a ALV Table column dynamically. But could not find any on a normal Table UI element. Can anyone please let me know how to do this or point me to an existing link?

I have a table with 6 columns and i want to make some of them read-only basing on some condition. I have bound the read-only attribute of the cell editors of the table columns to context attribute but by doing this the row is turning read-only and not the column. But i want the column to be read-only.

Thanks.

Aditya.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Aditya ,

try this classes to dynamically change proporties of column of a table

CL_WD_TABLE

CL_WD_TABLE_COLUMN

create object for these to classe in your method , like below code

DATA : lo_element TYPE REF TO if_wd_view_element,

lo_table TYPE REF TO CL_WD_TABLE,

lo_table_col TYPE REF TO CL_WD_TABLE_COLUMN.

CALL METHOD view->get_element

EXPORTING

id = TBL_DETAIL'

RECEIVING

element = lo_element.

lo_table ?= lo_element.

IF lo_table IS BOUND.

CALL METHOD lo_tton->get_column

EXPORTING

  • id =

index = '02'

RECEIVING

the_choice = lo_table_col

.

IF lo_table_col IS BOUND.

CALL METHOD lo_table_col->set_visible

EXPORTING

value = ' '.

ENDIF.

ENDIF.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>try this classes to dynamically change proporties of column of a table

>CL_WD_TABLE

>CL_WD_TABLE_COLUMN

I strongly recommend that you NOT follow this approach. Dynamic maniuplation of the UI element objects within WDDOMODIFYVIEW should be your absolute last resort. The recommendation is to bind the visible property of the TableColumn to a context attribute. You then control the visibility by simply changing the value of the corresponding context attribute.

Former Member
0 Kudos

Hi Thomas,

I agree. I want to do it in WDMODIFYVIEW only. But i am not finding any SET method for setting the read-only property to a table column. The above code will make the columns Invisible but that is not what i want. The column should be visible but in read-only mode. In the layout designer the Column does not have read-only property so i can bind it to a context attribute and manage. Only the CellEditor has the read-only property but by setting that, as i said, the row is turning read-only.

can you please advise?

Former Member
0 Kudos

read only you are setting not on the column but on the column content

Former Member
0 Kudos

Hello Aditya,

actually if you bind to specific column editor then only that column will become readonly. Could you check whether you have bound the same context attribute for all the column editors?

Regards,

Saravanan

Edited by: Saravanan N on Nov 11, 2010 1:04 AM

Former Member
0 Kudos

I have a different context attribute for each columns and could enable/disable each columns basing on condition.

Thanks for your answers. I have awarded the points.

jayanthi_jayaraman
Active Contributor
0 Kudos