cancel
Showing results for 
Search instead for 
Did you mean: 

How to Set a View within a ViewContainerUIElement programatically?

detlev_beutner
Active Contributor
0 Kudos

Hi there,

After having found the solution how to put views into a ViewContainerUIElement, now the next question arises:

I have got a ViewContainerUIElement with two possible views in it. I have put both views into the container, but only one appears (great, that's what I want).

But I have to determine at runtime which of the views has to appear. How can I set this?

Thanks in advance

Detlev

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Detlev,

one possible solution is to put an additional view without any elements into the container, which has to be the default view (the darker blue one ) and which is used to trigger the navigation to the desired view. Create two outbound plugs from the trigger view to the inbound plugs of the corresponding target views and decide which one you want to fire.

Hope that helps.

Regards

Stefan

detlev_beutner
Active Contributor
0 Kudos

Hi Stefan,

OK, this seems to be a starting point. One remark, one question:

1.) To describe the whole situation, I have a table on top, where I can choose one row. Below this there is a tab strip, whose content is dependent on the chosen row on the table. One of these tabs has got the ViewContainerUIElement as it's content, because here not only the values are dependent on the chosen row, but also the view itself. So when this tab is chosen, and the user changes the row chosen in the table, also the view under this tab has to change. That leads to the need to have the ability to fire from view a to view b and vice versa. So I did not add a third trigger view but have an outbound and an inbound plug on both views.

2.) Now the question: Where to fire the plug?!?!? I have implemented the decision if the plug from view A to view B should be fired (and the same within view B) within wdDoModifyView. This does not seem to work. Somehow this seems to be logic, because this method is for changing the view's content, but not for changing the view itself. But so - where can I fire these plugs (with the situation described above in mind)?

Thanks in advance

Detlev

Former Member
0 Kudos

Hi Detlev,

you can define outbound plugs from the view "owning" the ViewContainerUIElement with your two alternative views as targets, connect them to the inbound plugs of the target views and decide, which one to fire according to the selection in the table.

Hope that helps.

Regards

Stefan

Former Member
0 Kudos

Hi Detlev,

it's much simpler than you think. What you have is some view containing the table, let's call it T, and two (or more) alternatives for the content of your tab's view container, let's call these views A, B etc.

You should react to the onSelect event of the table and decide which of the alternatives A, B etc. is appropriate for the currently selected row. The event handler for this is written in T. You need outbound plugs a, b etc. in T and one inbound plug in every A, B etc. You then connect a with A's inbound plug, b with B's inbound plug etc.

In your event handler (in T!) you fire a, b etc. according to which alternative is desired.

General remark: The source of a navigational link need not be the view that is replaced! It can be any view that contains an event handler that needs to trigger navigation. The target of the link determines the view which is made visible. When making a view newly visible, other views may be replaced automatically, depending on the window's view hierarchy.

Best regards,

Thomas

Former Member
0 Kudos

Previous message by Thomas Chadzelek.

detlev_beutner
Active Contributor
0 Kudos

Hi Thomas called Armin and Stefan,

the solution Thomas suggested not only works, but seems to be the most consistent. Thanks a lot, your help is really appreciated.

Best regards

Detlev

Former Member
0 Kudos

Hi Detlev,

to be honest, i really can't find a difference in the solutions suggested by me (at least my second one, after you clarified the prerequisites) and Thomas's.

If you replace "owner of ViewElementUIContainer" with T, A and B with targets and "onSelect" with "according to the selection int the table" it's pretty the same

Anyway, it works and that's the only important thing.

Best regards

Stefan

detlev_beutner
Active Contributor
0 Kudos

He Stefan,

I just tried to edit my message, but you have been faster I wrote it before I realized that you had edited your last message.

Thanks a lot

Detlev

Former Member
0 Kudos

Hi Detlev,

yes, i revised my last post after 10 minutes, since i created a test project to ensure my final suggestion (in the meantime, i've learned to be as accurate as possible answering your posts 8-)). So, it's a 1:1 finally (Sorry, i'm just kidding).

Best regards

Stefan

Answers (0)