Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Making the certain columns as disable.

I am using a Complex UI Element - Table in my Web Dynpro. I am displaying 5 columns which are editable. i want to make disaable a column dynamically. How can we do that ?

replied

Hi Manjunath,

Sorry for the late reply was trying to code the desired functionality. Am not sure whether this is a good way of implementing your task or not but just giving out the way I know...

I had created 2 context nodes.

Node: DROPDOWN is used to store the dropdown values (Jan, Feb...)

Node: TABLE is a dummy node with no attributes used for binding to the table

Declare a variable (say GR_TABLE) of type CL_WD_TABLE in attributes tab of your view. Then in the wddomodifyview method just save the reference of your table UI element into this variable. (NOTE: TABLE is the name which I have given for my TABLE UI element in the view)

method WDDOMODIFYVIEW .

check first_time = abap_true.

wd_this->gr_table ?= view->get_element( id = 'TABLE' ).

endmethod.

Now coming to the main part of creating columns dynamically as per the selected month. I have put a pushbutton beside my DropDownByIndex which the user has to select after making a selction. This button triggers the action ONFETCH. We make use of the 2 classes CL_WD_TABLE & CL_WD_TABLE_COLUMN & the methods REMOVE_ALL_COLUMNS & ADD_COLUMN methods for achieving the desired output. But Manjunath my coding does not include creation of binding for the created columns. You will have to try code that yourself. You can find the necessary methods by going through CL_WD_TABLE & CL_WD_TABLE_COLUMN. Hope that this is helpful for you.

Regards,

Uday

Fill the respective month names in order to appear in the DropDownByIndex.

Coding inside the WDDOINIT method:

METHOD wddoinit .

  DATA: lv_node TYPE REF TO if_wd_context_node,
        lt_dropdown TYPE ig_componentcontroller=>elements_DROPDOWN,
        wa_dropdown TYPE ig_componentcontroller=>element_DROPDOWN.

        wa_dropdown-values = 'January'.
        append wa_dropdown to lt_dropdown.

        wa_dropdown-values = 'February'.
        append wa_dropdown to lt_dropdown.
        -
        -
        -
        -
       lv_node = wd_context->get_child_node( name = ig_componentcontroller=>wdctx_dropdown ).
       lv_node->bind_table( new_items = lt_dropdown ).
ENDMETHOD.

Coding for ONFETCH action triggered by pushbutton:

METHOD ONACTIONONFETCH .
  DATA: lv_node TYPE REF TO if_wd_context_node,
        lt_dropdown TYPE if_main=>elements_dropdown,
        wa_dropdown TYPE if_main=>element_dropdown,
        lead_selection_index TYPE i,
        lr_column type ref to cl_wd_table_column.

  wd_this->gr_table->REMOVE_ALL_COLUMNS( ).
  
  lv_node = wd_context->get_child_node( name = 'DROPDOWN' ).
 
  CALL METHOD lv_node->get_static_attributes_table
    IMPORTING
      table = lt_dropdown.

  lead_selection_index = lv_node->get_lead_selection_index( ).
  READ TABLE lt_dropdown INTO wa_dropdown INDEX lead_selection_index.

  CASE lead_selection_index.
    WHEN '9' or '11' or '4' or '6'. "Sep, Nov, April, June
      do 30 times.
        lr_column = cl_wd_table_column=>new_table_column( ).
        wd_this->gr_table->add_column( index = sy-index
                                       the_column = lr_column ).
      enddo.
    when '10' or '12' or '1' or '3' or '5' or '7'. " Oct, Dec, Jan, Mar, May, July, Aug
      do 31 times.
        lr_column = cl_wd_table_column=>new_table_column( ).
        wd_this->gr_table->add_column( index = sy-index
                                       the_column = lr_column ).
      enddo.
    when others. " Feb
      do 29 times.
        lr_column = cl_wd_table_column=>new_table_column( ).
        wd_this->gr_table->add_column( index = sy-index
                                       the_column = lr_column ).
      enddo.
  ENDCASE.
ENDMETHOD.

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question