cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically Changing Views in a View Container UI Element

Former Member
0 Kudos

Hi ,

I had a requirement :

There is 1 Main View - having a ViewContainer and two buttons.

There are 2 other Views - View1 and View2, which are to be called on clicking of these buttons.

On Clicking of 1st Button, The ViewContainer should load/show View1 and

On Clicking of 2nd Button, The ViewContainer should load/show View2.

How can i achieve this, keeping Main View always be displayed to user for clicking of another button?

Accepted Solutions (0)

Answers (3)

Answers (3)

arjun_thakur
Active Contributor
0 Kudos
Former Member
0 Kudos

Thanks to all,

I am able to do it now.

Former Member
0 Kudos

You can achieve this by binding both the views in your view container and firing the plugs

Check this link.

[]

Former Member
0 Kudos

Create a group element in view one with Button1 and Button2 in it.

Create two view containers view_container1 and view_container2 in the main view.

Create a node UTILITY with two attributes view_visible1 and view_visible2 of type WDY_UIE_LIBRARY_ENUM_TYPE in the context with default value 01

Bind view_container1 with view_visible1 and view_container2 with view_visible2 in the visible properties of both the containers respectively.

Create actions of Button1 and write the below code

DATA: lv_utility_node TYPE REF TO if_wd_context_node.

lv_utility_node = wd_context->get_child_node( name = 'UTILITY' ).

lv_utility_node->set_attribute( name = 'VIEW_VISIBLE1'

value = '02' ).

lv_utility_node->set_attribute( name = 'VIEW_VISIBLE2'

value = '01' ).

Create actions of Button2 and write the below code

DATA: lv_utility_node TYPE REF TO if_wd_context_node.

lv_utility_node = wd_context->get_child_node( name = 'UTILITY' ).

lv_utility_node->set_attribute( name = 'VIEW_VISIBLE1'

value = '01' ).

lv_utility_node->set_attribute( name = 'VIEW_VISIBLE2'

value = '02' ).

Now create two views (View1 and View2) with whatever elements you want to view in the view.

Now under windows you will have two nodes for the MAIN View. That's basically the view containers.

Bind view_container1 with View1 and view_container1 with View2.

Create the application and run.

Thanks

former_member40425
Contributor
0 Kudos

Hi Rohit,

You can do one thing Insert two VIEWCONTAINER UI Element.

Embed first view in one VIEWCONTAINER UI Element and second in the another VIEWCONTAINER UI Element.

Now create two context attributes(suppose visible1 and visible2) of type WDUI_VISIBILITY and bind these attributes to the visible property of viewcontainers respectively.

Now set these attributes in the onactions of both the buttons.

01 to make viewcontainer invisible

02 to make viewcontainer visible.

So in the onaction of first button set visible1 as 02 and visible2 as 01

and In the onaction of second button set visible1 as 01 and visible2 as 02 .

I hope it helps.

Regards,

Rohit