cancel
Showing results for 
Search instead for 
Did you mean: 

How to set column as ReadOnly/Output in wd ?

Former Member
0 Kudos

Hi

I need to set a specific column as read only in my webdynpro, but i want to do it by coding and not by binding an Element is there a way to do that?

Thanks Ami

Accepted Solutions (1)

Accepted Solutions (1)

amy_king
Active Contributor

Hi Ami,

You can set the whole column read-only dynamically as follows. The following example is written in hook method WDDOMODIFYVIEW where parameter VIEW is availble. If you perform this logic elsewhere, you'll need to get a reference to the view object with a call to  wd_this->wd_get_api( ).


   DATA lo_table       TYPE REF TO cl_wd_table.
   DATA lo_column    TYPE REF TO cl_wd_table_column.
   DATA lo_inputfield TYPE REF TO cl_wd_input_field.

* Get a reference to the table column's cell editor and set its readOnly property
   lo_table ?= view->get_element( 'TABLE_ID' ).
   lo_column ?= lo_table->get_grouped_column( id = 'TABLE_COLUMN_ID' ).

   lo_inputfield ?= lo_column->get_table_cell_editor( ).
   lo_inputfield->set_read_only( abap_true ).

Cheers,

Amy

Answers (3)

Answers (3)

Former Member
0 Kudos

For making a column(input field) as  read only.

1. Bind the read only property with a attribute and set the attribute value.

2. Set the input filed by-default as read only.

Now..

Either Add a text view in place of input field so 2 point and this will be same kind of. 

And on Modify-view replace the input field by text view during run time based on some action..

Former Member
0 Kudos

Hi Ami,

Try this according to your requirement :

DATA lo_nd_n_read_only TYPE REF TO if_wd_context_node.

  DATA lo_el_n_read_only TYPE REF TO if_wd_context_element.

  lo_nd_n_read_only = wd_context->get_child_node( name = wd_this->wdctx_n_read_only ).

  lo_el_n_read_only = lo_nd_n_read_only->get_element( ).

  lo_el_n_read_only->set_attribute(

    name =  `READ_ONLY`

    value = lv_read_only ).

Regards,

Shahir Mirza

Former Member
0 Kudos

You can write code in method 'WDDOMODIFYVIEW' of view to achieve this.