cancel
Showing results for 
Search instead for 
Did you mean: 

Looking for WD Abstract class for check box for table cell editor

Former Member
0 Kudos

Hi Friends

I am using a check box in a table to make the row read only/editable based on the check box value dynamically.

I am able to achieve that except one of the check box is not getting read only because I am not able to get the associated class.

Code under wddomodifyview

IF first_time EQ abap_true.

     DATA lo_table         TYPE REF TO cl_wd_table.

     DATA lt_grp_cols      TYPE cl_wd_abstr_table_column=>tt_abstr_table_column.

     DATA ls_grp_cols      LIKE LINE OF lt_grp_cols.

     DATA lt_cols          TYPE cl_wd_table_column=>tt_table_column.

     DATA ls_cols          LIKE LINE OF lt_cols.

     DATA lo_inp           TYPE REF TO cl_wd_abstract_input_field.

     "Get table reference

     lo_table ?= view->get_element('TABLE').

     "Get Columns of table

     lt_cols = lo_table->get_columns( ).

     "Check if no columns found

     IF lt_cols[] IS INITIAL.

       "get grouped columns list

       lt_grp_cols = lo_table->get_grouped_columns( ).

       "collect into columns table

       LOOP AT lt_grp_cols INTO ls_grp_cols.

         ls_cols ?= ls_grp_cols.

         APPEND ls_cols TO lt_cols.

       ENDLOOP.

     ENDIF.

"For each column and its editor, set the read only property

     LOOP AT lt_cols INTO ls_cols .

lo_inp ?= ls_cols->get_table_cell_editor( ).

Here the code work fine for input field but in case of checkbox in the row I am not getting any class for checkbox .

Kindly suggest.

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Sandeep,

You can make use of the class CL_WD_CHECKBOX, in this class you find the methods BOUND__PRIMARY_PROPERTY( ) & BIND_READ_ONLY( ).

Hope this resolves your issue.

Regards,

Rama

Former Member
0 Kudos

Thanks Rama,

In view modify I have used the below logic

here I have 2 check box and the 2nd check box I wanted to make read only(bold highlighted)

as per your suggestion I have made lo_Check as CL_WD_CHECKBOX.

LOOP AT lt_cols INTO ls_cols .

       IF SY-TABIX = 1.

         CONTINUE.

       elseif SY-TABIX = 21.

         lo_check ?= ls_cols->get_table_cell_editor( ).

       else.good

       " get the cell editor,

       lo_inp ?= ls_cols->get_table_cell_editor( ).

       ENDIF.




Now in button press who can we use its method

I have used this code in a button as per the doc and it working fine for input field

==========================================================

lt_attr_names =

   lo_node_info->get_attribute_names( ).

   lo_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

   lo_el->get_static_attributes(

       IMPORTING

         static_attributes = ls_data

     ).

   LOOP AT lt_attr_names INTO lv_attr_name.

    UNASSIGN <fs_value>.

       ASSIGN COMPONENT lv_attr_name OF STRUCTURE ls_data TO <fs_value>.

*        IF <fs_value> IS NOT INITIAL.

         lo_el->set_attribute_property(

           EXPORTING

             attribute_name = lv_attr_name

             property       = if_wd_context_element=>e_property-read_only

             value          = lv_lock

         ).

*      ENDIF.

   ENDLOOP.

ramakrishnappa
Active Contributor
0 Kudos

Hi Sandeep,

Is your requirement is to make check_box2 as read only always.

then,

   LOOP AT lt_attr_names INTO lv_attr_name.

    UNASSIGN <fs_value>.

       ASSIGN COMPONENT lv_attr_name OF STRUCTURE ls_data TO <fs_value>.

*        IF <fs_value> IS NOT INITIAL.


          if lv_attribute_name = 'CHECK_BOX2'.

               lv_lock = abap_true.

          endif.



         lo_el->set_attribute_property(

           EXPORTING

             attribute_name = lv_attr_name

             property       = if_wd_context_element=>e_property-read_only

             value          = lv_lock

         ).

*      ENDIF.

   ENDLOOP.


If your requirement is different, describe it in detail.

Regards,

Rama