on 12-18-2012 7:07 PM
Hi
Is there a way to set the ENABLE property of an UI-element button dynamically without creating a new attribute and bind it to the element and dynamcally change its value?
I want to find a way to do it without the creation of the attribute because i have severals buttons in my WD application and i dont want to create a lot of attributes in my context for each button (every button is enable/disable in different situations).
Thanks
Elad
Hi Elad,
You can toggle a button's enabled property with the following code (here, wd_this refers to the current view)...
DATA lo_view TYPE REF TO if_wd_view.
DATA lo_button TYPE REF TO cl_wd_button.
DATA lv_enabled TYPE wdy_boolean.
* Get a reference to the VIEW, casting to the appropriate interface
lo_view ?= wd_this->wd_get_api( ).
* Get a reference to the BUTTON that needs to be enabled/disabled
lo_button ?= lo_view->get_element( 'BUTTON' ).
* Determine if BUTTON is currently enabled or disabled
lv_enabled = lo_button->get_enabled( ).
* Toggle BUTTON enabled or disabled
CASE abap_true.
WHEN lv_enabled.
lo_button->set_enabled( abap_false ).
WHEN OTHERS.
lo_button->set_enabled( abap_true ).
ENDCASE.
Cheers,
Amy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Elad,
See as here we dont have any primary atribute mentioned in the document for button. In document they are talking about e.g. input field which whose value is binded to some context attribute. here in our case there is nothing like which can be binded(In button). Anyways we are trying to ignore bindings here.
So our button will have no reference with any context attribute. Hence its a problem here. So I suggest if it dont work out. try to look whether we can get a UI element based on their ID. because here I am not able to reach to UI button as there is no context. If get it done. please share for sure.
nice question
HAPPY ABAPing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Elad,
Yes you can do it, by making use of set_attribute_property method.
For details,
you can go through...
http://help.sap.com/saphelp_nw04s/helpdata/en/45/d44e0cdff073b1e10000000a11466f/content.htm
I hope it helps.
HAPPY ABAPing
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.