Problem on Subform in same time on main and dialog Form

Hi,

Since Servoy 3.5, I can open more than 1 Form in dialog.

It’s really usefull but I have a problem with subforms.
I have a First form (Form1) with subform (Subform1)
http://www.imagup.info/images/06/119271 … e_open.JPG

I have a second form (Form2) with the same subform(Subform1). When I open this second form in Dialog. Subform1 from Form1 disappear and sometime become a grey rectangle.

http://www.imagup.info/images/06/119271 … r_open.JPG

How can I solve this problem?

Regards.

Hi Pierre-andre,

Just like you can’t show the same form twice (or more) on 1 form using tabpanels you can’t show it twice (or more) in dialogs.
What you need to do is create a new instance of that form and use that in the dialog. You can do this dynamically or in design time (dupe a form).

Hope this helps.

You can do this dynamically or in design time (dupe a form).

I know how duplicate a form in design mode but how can I do it dynamically ?

To create a new form instance you use the following syntax:

application.createNewFormInstance(originalFormName,newFormName)

After this you can address that form by the name you gave it.
See further in the example code (control-n in the editor):

//Create a new form instance
var ok = application.createNewFormInstance('orders','orders_view');
if (ok)
{
	application.showFormInDialog(forms.orders_view)
	//forms['orders_view'].controller.show()
	//forms.xyz.elements.myTabPanel.addTab(forms['orders_view'])
	//forms['orders_view'].elements.mylabel.setLocation(10,20)
}

Hope this helps.

What you need is

application.createNewFormInstance() 

or something like that. That allows you to “clone” a form by method.

Hey Robert, this happens all the time now :lol:

We should do it like this:

Marcel answers between 8 and 12
You between 12 and 16
I between 16 and 20

:D

Hi Patrick,

Very true but I am not always available that time ;)
Maybe we should use a roster. I am sure someone can make a Servoy solution for that. :D

BTW. If you want to clone that original form 1 you also have to take care of cloning the subform (in the tab panel) as well. So cloning a form with a tab panel showing other forms is more tricky. Basically you have to clone the form with the tab panel, remove all tabs, create clones for all forms that were shown in tabs and add those as tabs again. A bit complicated…

Oh ok ! It haven’t see this method :)

I’ve try this code :

application.createNewFormInstance('From','NewForm');
var nom = "NewForm"
elements.entete.addTab(forms[nom],'NewFormName',"NewFormName2")

It seems that forms[nom] don’t work.
It work if I use directly forms[‘NewForm’] .

I’m my case, I have to use variable :confused:

We should do it like this:

Marcel answers between 8 and 12
You between 12 and 16
I between 16 and 20

Looks like the 2007/08 competition for 'Most answers on the Forum" is going to be pretty intense this year. I guess it allows us mere mortals to ‘vote’ for our favourite ‘responder’ by choosing carefully the time we post a question :)

I didn’t know there was a competition :)