cancel
Showing results for 
Search instead for 
Did you mean: 

Change atributes inputfield.

Former Member
0 Kudos

Hi,

I've a radiobutton and a input field. I've a action for the radiobutton. I want change the method for the action. I want that when the radiobutton is selected, the inputfield -> enabled = false. How can i do?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

mohammed_anzys
Contributor
0 Kudos

Hi

Create one more attribute in teh context , type WDY_BOOLEAN , and give the default value as false ,which will enable and disable the field on action of the radio button.Bind this new attribute to the enabled field of your UI elemment , here its the input field.

During the action set the attribute value = true.

Thanks

Anzy

Former Member
0 Kudos

Hi,

But How can I change this value?:

read_only->defaultvalue = "X" ?

Can you write me the code please?

mohammed_anzys
Contributor
0 Kudos

Hi

You can do like this ,

Data: mynode type ref to if_wd_context_node.

mynode = wd_Context->get_Child_Node( `MYNODE` ).

CALL METHOD MYNODE->SET_ATTRIBUTE

EXPORTING

  • INDEX = USE_LEAD_SELECTION

VALUE = 'X'

NAME = 'READONLY'

.

Former Member
0 Kudos

In the context, declare an attribute read_only of type char01.

In the event handler of the radio button,

data: lr_element type ref to if_wd_context_element.

lr_element = wd_context->get_element( ).

lr_element->set_attribute(

exporting

name = 'READ_ONLY'

value = abap_true).

If you want it to be editable when you launch the view, make the default value of read_only as initial. You can make it true on the radio button event. Or vice versa.

Regards,

nithya

mohammed_anzys
Contributor
0 Kudos

Hi

I will provide a step by step approach for you to implement this.

1.Create a node 'MYNODE' in your view context.

Create three attributes in under this node.

a) radiobtn type xfeld.

b) dsply type string.

c) enabled type wdy_boolean ( make default value as ' ' ) so that it will not be enabled.

2. Create UI elements.

In your view create the UI elements.

a) create radio button and bind it with radiobtn from the context.

b) create input field and bind it to dsplay from the context

c) Create an action for the radio button on toggle, let it be onSelect.

d) Bind input field enable property to enabled from the context.

3. Implement the method onSelect.

In the onSelect method , write the following code.

Data: mynode type ref to if_wd_context_node,

myval type xfeld.

mynode = wd_Context->get_Child_Node( `MYNODE` ).

CALL METHOD MYNODE->GET_ATTRIBUTE

EXPORTING

  • INDEX = USE_LEAD_SELECTION

VALUE = 'myval

NAME = 'radiobtn'

if myval = 'X'.

CALL METHOD MYNODE->SET_ATTRIBUTE

EXPORTING

  • INDEX = USE_LEAD_SELECTION

VALUE = ' '

NAME = 'enabled'

.

else.

CALL METHOD MYNODE->SET_ATTRIBUTE

EXPORTING

  • INDEX = USE_LEAD_SELECTION

VALUE = ' X'

NAME = 'enabled'

.

endif.

Please correct the syntax mistake if any, i hope this will solve your problem

Cheers

Anzy

Award points if this solves your problem

Former Member
0 Kudos

Hi Mohammned and Nithya,

Thank you for your answers. I've solver my problem.

Thanks.

Answers (1)

Answers (1)

Former Member
0 Kudos

Declare a context attribute "read_only" and bind it to the read_only property of your input field. In the event handler of the radio button, set this attribute to X or space. It will automatically reflect in your input field.

Hope this helps.

Regards,

Nithya