Page 1 of 1

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

Posted: Mon Feb 24, 2020 3:25 am
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

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

Posted: Wed Mar 04, 2020 12:15 pm
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 1486 times

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

Posted: Wed Mar 04, 2020 1:30 pm
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

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

Posted: Fri Mar 06, 2020 11:12 am
by Dino
Thank you!