cancel
Showing results for 
Search instead for 
Did you mean: 

Show and Hide UI Elements

Former Member
0 Kudos

Hi,

I want to show and hide the inputfields on the buton click.

I want to do it without any context attributes.

is it possible?

is it possible to change the control properties without contextattributes in codeing?

Regards,

Kumar K

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Yes you change the properties without binding to some context atrribute.

Here's a sample code for it. You may code this in WDDOMODIFYVIEW method.



data: lr_container type ref to cl_wd_uielement_container.
data: lr_inp type ref to cl_wd_uielement.

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).


lr_inp = lr_container->get_child(
    id        =     'INPUT_FLD_1'
*    index     = index
       ).

lr_inp->set_enabled( value =  abap_false  ).

Regards,

Runal

Former Member
0 Kudos

its working but

im getting error in the folowing line when i write the same code in Button Onaction

lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).

Please let me know hopw to get the Current view object

Regards,

Kumar k

Former Member
0 Kudos

View is not available in the button action method, it is available only in viewmodify. Hence the error.

TCreate an attribute l_view and try saving the reference of the view in this attribute in viewmodify method .

wd_this->l_view  = view.

and then in your button action, write as follows

lr_container ?= wd_this->l_view->get_element( 'ROOTUIELEMENTCONTAINER' ).

Try this.It may help.

Regards,

Radhika.

Answers (4)

Answers (4)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

The suggestion to use the WDDOMODIFYVIEW approach - although technically possible is not the SAP recommended approach. It is recommended that instead you bind context attributes to the visible property of the UI element and control this by changing the context attribute. This way the definition is made independent up the UI element itself and done via context binding. This makes the functionality more reusable and easier to maintain. The WDDOMODIFYVIEW should only be used as a last resort when you have dynamically generated UI elements and you need to create or maniuplate them.

former_member230839
Participant
0 Kudos

Hi kuppusamy,

As i told you in the same thread.

if you want to use the View reference in any of the methods please maintain a view level attribute of type IF_WD_VIEW and in METHOD WDDOMODIFY just assign the VIEW importing parameter direct ly WD_THIS->CURR_VIEW if the attribute name if curr_view. so you can get the current view reference in any of the methods like WD_THIS->CURR_VIEW.

Regards,

Anil kumar G

Former Member
0 Kudos

its working but

i have to do that in button click

Former Member
0 Kudos

hi,

You may create an attribute in the view controller as


  GV_VIEW	type ref to IF_WD_VIEW.

Then in the event handler method of the button put this code.


data: lr_container type ref to cl_wd_uielement_container.
data: lr_inp type ref to cl_wd_uielement.
data: value_enbl type abap_bool.

lr_container ?= wd_this->gv_view->get_element( 'ROOTUIELEMENTCONTAINER' ).


lr_inp = lr_container->get_child(
    id        =     'INPUT_FLD_1'
*    index     = index
       ).

  lr_inp->set_enabled( value =  abap_false  ).

And in the WDDOMODIFYVIEW mwthod put this peice of code

method wddomodifyview .

wd_this->gv_view = view.

endmethod.

Regards,

Runal

former_member230839
Participant
0 Kudos

Hi Kuppusamy,

You can do this without context nodes also by getting the reference of the UI elements directly..

For example in the below code iam making invisible the UI Element container.

data : lo_ui_ovr type ref to if_wd_view_element.

data : lo_cont type ref to cl_wd_uielement_container.

data : view_1 type ref to if_wd_view.

lo_ui_ovr = curr_view->get_element( id = 'NODE_CONT' ).

lo_cont ?= wd_this->lo_ui_ovr.

lo_cont->SET_VISIBLE( abap_false ).

This code will get the UI element of ID 'NODE_CONT' and make that invisible.

here the CURR_VIEW is the cyrrent view reference which will be avaliable in WDDOMODIFY method. but if you want to get this in any method just maintain a View level attribute of type IF_WD_VIEW and store the curr_view as the current view from WDDOMODIFY method and access that any method like

WD_THIS->CURR_VIEW.

Regards,

Anil kumar G

Edited by: Anil Kumar on Jun 1, 2009 2:37 PM

Edited by: Anil Kumar on Jun 1, 2009 2:37 PM