View... how to really close it? destroy, etc.

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

View... how to really close it? destroy, etc.

Post by Dino »

Hi

Current examples, use a container view and a menu inside an App Drawer.
The menu can call a view, but it only opens it, never closes it. So if you select the same view again, it was always open, and you resume to see the old values. Plus if you have a large number of views, it affects the performance.

What would be the suggested way to close, remove from memory, destroy, the view once you select to go to another view?

thank you
JamesDuignan
Posts: 85
Joined: Thu Nov 26, 2015 1:43 pm

Re: View... how to really close it? destroy, etc.

Post by JamesDuignan »

Hi,

So there are is no way currently for the views to be closed, as you have found.

So the way I see it there are two ways you could possibly do this.
A) Use the prepare event in the views to re-initialize the values in the view.

But seeing as how you are talking about actually destroying the instances of each view I think that you may need a little bit more logic for what you want to achieve.
B) dynamically create and destroy the view instances as you need them.

1. Only have a single prim_view defined for the webpage, call it something like "currentview"

Code: Select all

Define_Com Class(#prim_view) Name(#CurrentView) Reference(*DYNAMIC) Parent(#ViewContainer)
2. Use the click events of the menu items, rather than the view property of the menu item to show you views. In the event to cast the definitiions view to "currentview"

Code: Select all

Evtroutine Handling(#MenuItem1.Click)

Define_Com Class(#View1) Name(#View1) Reference(*DYNAMIC)


If (#CurrentView *IsNot *NULL)

#CurrentView <= *NULL

Endif

#View1 <= *New #View1

#CurrentView <= #View1

#CurrentView.Show

#View1 <= *NULL

Endroutine
Here is an export of how this can be achieved
QuickExportViewTest.zip
(10.91 KiB) Downloaded 1485 times
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: View... how to really close it? destroy, etc.

Post by MarkD »

This previous forum topic (including the other topics, documents and example code it points to) might help you to understand how to destroy any VL object, including a view : viewtopic.php?f=3&t=1377&p=2830&hilit=destroy#p2830
User avatar
Dino
Posts: 472
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: View... how to really close it? destroy, etc.

Post by Dino »

Thank you!
Post Reply