cancel
Showing results for 
Search instead for 
Did you mean: 

How to change Parent of UI element at Runtime

former_member196517
Contributor
0 Kudos

Hi Colleagues,

I have a requirement wherein i have to change a parent of a UI element GROUP to Transparent container , it is residing within Tray. I am using SET_PARENT from CL_WD_UIELEMENT but this method is executed successfully also but my view still remains the same and i cannot see parents changed in view.

Any idea.. do i need to refresh ,invalidate or anything else.. ?

Anuj

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I guess you will want to trigger changing the parent element based on some action, say a button click. So in your event handler, you can set a context attribute 'change' to denote whether the parent needs to be changed or not. In the modifyview method, read this attribute, and based on the value, do the following:

data: lr_group type ref to cl_wd_group,

lr_tray type ref to cl_wd_tray,

lr_transp type ref to cl_wd_transparent_container.

lr_group ?= view->get_element( 'GROUP' ). "Replace with UI Element ID of group

lr_tray ?= view->get_element( 'TRAY' ). "Replace with UI Element ID of tray

lr_transp ?= view->get_element( 'TRANSP' ).

lr_tray->remove_child( 'GROUP' ).

lr_transp->add_child( lr_group ).

This code works, I have tried it. For some reason, unset parent and set parent do not reflect the changes in the view even though the attributes get changed. I dont know why that doesnt work. This method works though.

Hope this helps.

Regards,

Nithya

Answers (2)

Answers (2)

Former Member
0 Kudos
Former Member
0 Kudos

You can get the reference of the group, do a remove_child first. Then get the reference of the Tray element, and do an add_child.

This should be done in the modifyview method.

Regards,

Nithya

former_member196517
Contributor
0 Kudos

I am doing all this in a PreExit of a modifyview....