cancel
Showing results for 
Search instead for 
Did you mean: 

Change Text of UI Element Dynamically

Former Member
0 Kudos

Hi

I want to change the Text of the button on clicking it. Its like Toggle Button.

Example : start/stop button

Regards

Piyush Deora

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

Approach 1:

You can do it by binding an attribute to the "text" prpperty of the button,

at run time just get the attribute and accordingly set the attribute value. Depending on the attribute value your button text will be changed.

Approach 2:

With the help of implicit variable "view" we can get the button by passing the button "ID".

class for button: cl_wd_button.

Remember "view" is a impoting parameter of method wddomodifyview and only available there so if you want to create a button at some where else then you must this variable. you can declare the attribute of IF_WD_VIEW type and can take the instance of "view". With this you can access "view" at any point of time except in method "wddoinitialize".

Code to take reference of "view" :

m_view type if_wd_view "this should be declared in Attribute tab of View

if first_time = 'X'. " you will get "first_time" for free in the wddomodifyview method.

wd_this->M_view = view

endif.

I would prefer Approach 1.

Hope it will help.

Former Member
0 Kudos

Hi

You can use the methods of class CL_WD_TOGGLE_BUTTON inside modify view and can change the text dynamically.

Regards

Sarath

Former Member
0 Kudos

Hi

u can create an attribute of type string. and bind it to the text property of the toggle button.

lv_initial is the flag to check if the method is triggered for the first time or not.

when it is triggered for first time u set the text as start and when it is triggered for second time u give the text as stop.

when u click on the button. in action handler method u can code like this.

data lv_initial type boolean.

if lv_initial = ' '.

lo_el_element->set_attribute

exporting

name = 'button' "name of the attribute bound with text property

value = 'Start'.

lv_initial = 'X'.

endif.

if lv_initial = 'X'.

lo_el_element->set_attribute

exporting

name = 'button'

value = 'Stop'.

endif.

regards

chythanya