cancel
Showing results for 
Search instead for 
Did you mean: 

enable/disable based on the selected drop down value

Former Member
0 Kudos

Dear All,

I have 3 drop down(drop down by key)boxes.

Based on the selected value of First drop down one of the remaining drop down has to be disabled and the other shud be enabled.In case user changes again the first dropdown value the enabled drop down shud be disabled and the disabled shud be enabled.

Scenario:First Drop Down values:

Catogery(1st Drop Down):1.Two - Wheeler

2.Four Wheeler

If Two Wheeler selected from the above drop down box Type of 2 wheeler(2nd drop down)drop down shud be enabled and the Type of 4 wheeler(2rd drop down) drop down shud be disabled and the vice versa.

Pls suggest.

Thanks,

Reddy.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi sudhir,

Create two attributes of type WDY_BOOLEAN, say DROP2 and DROP3 bind these attributes to 2nd and 3rd dropdown

ENABLED property.

Now in ON_SELECT of first drop down event write code like this..

First get the selected value in drop down, store in local variable. for example.

DATA lo_nd_segment1 TYPE REF TO if_wd_context_node.
  DATA lo_el_segment1 TYPE REF TO if_wd_context_element.
  DATA ls_segment1 TYPE wd_this->Element_segment1.
  DATA lv_segment TYPE wd_this->Element_segment1-segment.

*   navigate from <CONTEXT> to <SEGMENT1> via lead selection
  lo_nd_segment1 = wd_context->get_child_node( name = wd_this->wdctx_segment1 ).

*   get element via lead selection
  lo_el_segment1 = lo_nd_segment1->get_element( ).

*   get single attribute
  lo_el_segment1->get_attribute(
    EXPORTING
      name =  `SEGMENT`
    IMPORTING
      value = lv_segment ).

IF lv_segment = 'Two - Wheeler'.
* set single attribute
    lo_el_context->set_attribute(
      name =  `DROP2`
      value = ABAP_TRUE ).

* set single attribute
    lo_el_context->set_attribute(
      name =  `DROP3`
      value = ABAP_FALSE ).

ELSEIF lv_segment = 'Four Wheeler'.
* set single attribute
    lo_el_context->set_attribute(
      name =  `DROP2`
      value = ABAP_FALSE ).

* set single attribute
    lo_el_context->set_attribute(
      name =  `DROP3`
      value = ABAP_TRUE ).

ENDIF.

Cheers,

Kris.

Former Member
0 Kudos

Thanks for the responses.I solved the problem by looking at WDR_TEST_EVENTS component.I am using the following code in onselect methos of the first drop down..

method ONACTIONVEHICLETYPE .

DATA key type string.

DATA lo_el_context TYPE REF TO if_wd_context_element.

lo_el_context = wd_context->get_lead_selection( ).

  • display the value of the KEY event parameter

key = wdevent->get_string( name = 'KEY' ).

IF key eq 1.

lo_el_context->set_attribute(

name = `TWOWHEELER_ENABLE`

value = abap_true ).

lo_el_context->set_attribute(

name = `TWOWHEELERINPUT_ENABLE`

value = abap_true ).

lo_el_context->set_attribute(

name = `FOURWHEELER_ENABLE`

value = abap_false ).

lo_el_context->set_attribute(

name = `FOURWHEELERINPUT_ENABLE`

value = abap_false ).

ELSEIF key eq 2.

lo_el_context->set_attribute(

name = `TWOWHEELER_ENABLE`

value = abap_false ).

lo_el_context->set_attribute(

name = `TWOWHEELERINPUT_ENABLE`

value = abap_false ).

lo_el_context->set_attribute(

name = `FOURWHEELER_ENABLE`

value = abap_true ).

lo_el_context->set_attribute(

name = `FOURWHEELERINPUT_ENABLE`

value = abap_true ).

ENDIF.

endmethod.

Answers (1)

Answers (1)

Former Member
0 Kudos

I would do the following.

create one attribute dd_enabled of type wdy_boolean.

Bind dd_enabled to the property enabled for the 2nd and third Dropdowns.

Select the inversion of the property value when you bind it to the third dropdown. This way it will function as toggle.

Set the value to dd_enabled according to the slection value of DropDown 1.