Is it necessary to run destructor()

  1. If a form is attached to a window, will window.destructor() remove the form?
  2. Once a form in the window is sent, I usually run window.hide(). When I need to fill another form, a new window will be created. Is it ok, should I run window.destructor() before its creation?
  3. For the dhxGrid, will grid.destructor() remove the grid.data?
  4. For the nested layouts, is it necessary to destructor them recursively, or just destructor the outer most one? Will it remove the widgets in the layout(s)?

Thx

Yes, it should, but… The problem was confirmed. We’ll try to fix it in one of the future updates.
I’ll inform you about any progress on this issue.

  1. Once a form in the window is sent, I usually run window.hide(). When I need to fill another form, a new window will be created. Is it ok, should I run window.destructor() before its creation?

Please, note that hiding a window you can show it back using the show(). there is no actual need to destruct it each time you want to show it back or add a new content to it.

if a “new” window will have the same object name:

const myWin = new dhx.Window()
myWin.attach(form1)
//then
const myWin = new dhx.Window()
myWin.attach(form2)

yes, it is recommended to destruct the window and object it contains (if it is needed and you’re not planning to use it anymore)
but you may create several windows:

const myWin1 = new dhx.Window()
myWin1.attach(form1)
//then
const myWin2 = new dhx.Window()
myWin2.attach(form2)

so you won’t have destruct the objects and operate with them until there is a need to destruct it from your page
or you can swap the attached content from the same window without destructing it:

const myWin = new dhx.Window()
myWin.attach(form1)
//then
myWin.attach(form2) //now a new form is displaying in the same window.
//the old form won't be displayed anywhere, but you can attach it back to your window when you need it:
myWin.attach(form1)
  1. For the dhxGrid, will grid.destructor() remove the grid.data?

No, the data object will keep, as it may be the external dataCollection object which can be used by other components

  1. For the nested layouts, is it necessary to destructor them recursively, or just destructor the outer most one? Will it remove the widgets in the layout(s)?

As I’ve mentioned before - yes, calling the destructor() method for the layout SHOULD destruct all the nested components, but at the moment there is an issue with that logic, and the nested components are not destroying, so currently I suggest to destroy all the nested components manually.
I’ll inform you when this problem will be fixed.

We fixed your reported problem, where destructing the parent widget the nested one was not destructed.
Now this scenario should work correctly since the dhx.Suite 8.3.9 update.

Thank you for your report.
Best regards.

1 Like

Hello, I am new to DHTMLX Suite 8 and I have some issues with the destruction of the views in my app. I have built an app, following the Optimus framework, whose main view is composed by a vertical layout with a sidebar and a main content. When clicking on one of the items of the sidebar, a “viewChange” event is fired, the app.activeSection attribute changes and the view inside the layout main content cell changes too using: this.show(this.layout.getCell(“content”), *NewView) [this is the toplayout/main view], where *NewView changes based on the value assigned to app.activeSection.
After some “viewChange” events are fired, I was expecting the number of the views to not increase and that for each “viewChange” event the previous view would be completely deleted and the NewView would be created. Instead, the number of the DOM nodes seems to increase everytime a new “viewChange” event is fired. This is confirmed looking at the memories’ snapshots, where it seems that the expected deleted views continue to stay in memory.

Some more info, I am using DHTMLX Suite 8.3.10.

Thx