I am trying to create a new form using the SOM based on the template form. For some reason this does not seem to be working and I am wondering if its a bug in Servoy OR my misunderstanding of the notes.
The code example is:
var subForm = solutionModel.newForm(‘childForm’,‘myServer’,‘myTable’,null,true,800,600);
var superForm = solutionModel.newForm(‘childForm’,‘myServer’,‘myTable’,null,true,800,600);
subForm.extendsForm = superForm;
I am subForm is the form your wishing to extend and superForm is the template you want subForm based on. SO:
var subForm = solutionModel.newForm(‘myNewForm’,‘muServer’,‘myTable’,null,true,800,600);
var superForm = forms.template_form
subForm.extendsForm = superForm;
Having tried this all ways I can think of superForm makes no difference to myNewForm which is created correctly but has no features. I would note that template_form has been used extensively throughout the app to extend functionality to other forms in the solution, so generally it works !
you can not amend an existing runtime form using the solution model
Sure you can. Just get the JSForm object via solutionModel.getForm(formName) and alter it. At the end you call forms.formName.controller.recreateUI() and you are done.
Gordon:
2) you can however clone an existing form and then add features to the cloned form using the solution model
Yes, you can do this but like explained in point 1 it’s not the only way.
Gordon:
3) effectively the runtime and solution models co exist but are not interchangeable.
Not true, see answer point 1.
Gordon:
4) once a form has been created by the solution model and rendered to the screen you can not make changes to it after the fact.
Yes you can. But OR you make sure the form is no longer displayed when you call solutionModel.removeForm() which destroys the form in memory OR you don’t destroy the form and call controller.recreateUI() after your changes. This last approach doesn’t require you to not display the form.
Brilliant - that makes a great deal of sense. I did not see any of these points in the WIKI and I think this would be a great addition. Thanks very much for you help guys - good to clarify understanding and learn this stuff
One limitation to note with the solutionModel + recreateUI() route is that you cannot alter the datasource and call recreateUI() - as the name implies you can alter the UI, not the data this UI is build on.