cancel
Showing results for 
Search instead for 
Did you mean: 

Disabling button if the check box is uncheked

Former Member
0 Kudos

Hai all,

I want to enable the button once checked the check box. Am using this code,

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->Element_context.

DATA lv_check_button TYPE wd_this->Element_context-check_button.

lv_check_button = 'ABAP_TRUE'.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_context IS INITIAL.

ENDIF.

  • set single attribute

lo_el_context->set_attribute(

EXPORTING

name = `CHECK_BUTTON`

value = 'lv_check_button' ).

Am getting it.

Once I uncheck the check box means the button has to be disabled. What can I do to resolve this. Pls give some suggestions.

Thanks in Advance,

Nalla.B

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi.,

In your code ., first read the check box value. ,

if it is checked.,

lv_check_button = 'ABAP_TRUE'.

else

lv_check_button = 'ABAP_FALSE'.

endif.

then set sttribute property of button.

hope this helps u.,

reply if u need some more clarifications.,

Thanks & Regards

Kiran

Former Member
0 Kudos

Hai Kiran,

It will be useful... Can u pls explain me how to read the checkbox value.... Then it will be easy to use ur code.

Thanks in advance.

Nalla.B

Former Member
0 Kudos

hi Nalla,

Use get_attribute to read that value of check box.

For example CHECK is the attribute of check box.

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `TEXT`

IMPORTING

value = lv_text ).

lv_text contains check box value.

cheers,

Kris.

Former Member
0 Kudos

hai kris,

I did the same But if i uncheck the checkbox means that button is still enabled.....

I hav bounded that check attribute to the 'checked' propertyof the checkbox UI element......

Can u pls help me where i went wrong. Tis s my coding

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->Element_context.

DATA lv_check TYPE wd_this->Element_context-check.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_context IS INITIAL.

ENDIF.

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `CHECK`

IMPORTING

value = lv_check ).

"IF lv_check EQ ' X'.

"DATA lo_el_context TYPE REF TO if_wd_context_element.

" DATA ls_context TYPE wd_this->Element_context.

DATA lv_check_button TYPE wd_this->Element_context-check_button.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • @TODO handle not set lead selection

IF lo_el_context IS INITIAL.

ENDIF.

if lv_check eq 'X'.

lv_check_button = 'ABAP_TRUE'.

else.

lv_check_button = 'ABAP_FALSE'.

endif.

  • set single attribute

lo_el_context->set_attribute(

EXPORTING

name = `CHECK_BUTTON`

value = 'lv_check_button' ).

Thanks in advance,

Nalla.B

Former Member
0 Kudos

Hi Nalla,

This is the code i am using it is working for me..

I created two attributes enable and check, and i bind check with checkbox checked property and enable with button enable property.

Write this code on_toggle action of check box.

DATA lo_el_context TYPE REF TO if_wd_context_element.

DATA ls_context TYPE wd_this->Element_context.

DATA lv_check TYPE wd_this->Element_context-check.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->get_attribute(

EXPORTING

name = `CHECK`

IMPORTING

value = lv_check ).

if lv_check = 'X'.

DATA lv_enable TYPE wd_this->Element_context-enable.

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • set single attribute

lo_el_context->set_attribute(

name = `ENABLE`

value = ABAP_TRUE ).

else.

  • set single attribute

lo_el_context->set_attribute(

name = `ENABLE`

value = ABAP_FALSE ).

endif.

Cheers,

Kris.

Former Member
0 Kudos

Thank u very much kris.... Am getting it.

Thanks for ur kind and helpful solutions.

Nalla.B

Answers (1)

Answers (1)

Former Member
0 Kudos

HI ,

I would have created a new context attribute of type WDY_BOOLEAN and bound that to the enabled property of the button.

Now I would create a event handler to the 'On toggle' event of the checkbox .

The 'ontoggle' event provides a standard paramater , "checked" that holds the current state of the checkbox(01-checked, ' ' -unchecked).

Based on the value of the paramater, I would have set the value of the attribute bound to the 'enabled' property of the button.

Thanks,

Aditya.

Former Member
0 Kudos

Hai Aditya,

Now am able to enable the button wen i check the check box. If I uncheck the checkbox means it is not disabled, So I want to disable it if i uncheck the checkbox.

Kindly help me with some example in coding.. Since Am new to webdynpro.

Thanks in advance,

Nalla.B