on 2008 Sep 19 2:16 PM
Hello,
Is there a method which gives me the object-reference of an UI-element when I know the ID of this element?
For example I have a button with the ID "bt_ok". Now I want to have the reference of this object, but I only know it's ID.
Is there a possibility to do this?
Best regards & Thanks
Yes, but you can only do this inside method WDDOMODIFYVIEW. Here's a sample code:
* This ID belongs to a Transparent Container UI element
CONSTANTS:
lc_header_id TYPE string VALUE 'TCN_HEADER'.
DATA:
lr_view_elem TYPE REF TO cl_wd_uielement.
* You cast to generic cl_wd_uielement class since setting enabled property is a common operation.
* In case you need to do something more specific you would cast to the UI element's specific subclass
lr_view_elem ?= view->get_element( id = lc_header_id ).
lr_view_elem->set_enabled( value = abap_true ).
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Adding to Alejandro Bindi's code
you can even code it in any other method if you have the view instance available.
create a context attribute of type ref to if_wd_view, say view_01.
In do modify,
Save view reference in the attribute as follows:
wd_context->set_attribute(
exporting
name = `view_01`
value = view ).
Yes Reema, that may work, but it's not a good practice. There's a reason the view reference is available in WDDOMODIFYVIEW only.
Besides, in case you still want to do this, it's preferable to save the if_wd_view view reference as a controller attribute rather than saving it in the context, because it's faster and easily accesible.
Edited by: Alejandro Bindi on Sep 19, 2008 7:16 PM
User | Count |
---|---|
70 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.