Hello again,
does anybody know, how to change the height f.e. of “trailing summary” of a form during runtime?
Thanks!
MIKE
Hello again,
does anybody know, how to change the height f.e. of “trailing summary” of a form during runtime?
Thanks!
MIKE
Hi Mike.
Form parts are not properties you can change during runtime. I.e. these can’t be changed on the form instance.
What you can do however is change the blueprint of these forms at runtime and let Servoy create a new instance of this using the SolutionModel like so:
// Get the form blueprint and then the summary blueprint of that
var _oForm = solutionModel.getForm(myFormName),
_oPart = _oForm.getPart(JSPart.TRAILING_GRAND_SUMMARY);
// Lets change the height of this summary part to, lets say, 30
_oPart.height = 30;
// Now let Servoy (re)create the form instance using this altered blueprint
forms.myFormName.controller.recreateUI();
Hope this helps.
Hi Roclasi,
I tried, but it doesn’t work! I get the following error:
TypeError: Cannot call method “getPart” of undefined
in the line:
_oPart = _oForm.getPart(JSPart.TRAILING_GRAND_SUMMARY);
Any idea? Any more ideas?
MIKE
Hi Mike,
Seems your _oForm doesn’t contain a JSForm object.
Can you show me your code ?
Particularly the part where you get the form object → “_oForm = solutionModel.getForm(myFormName)”.
What are you passing to the getForm() function ?
Hi!
It’s the code like you sent me. Ah, what I didn’t tell you is, that I’m using the framework!
var _max = 3;
var _form = solutionModel.getForm("xy");
var _part = forms[_form].getPart(JSPart.TRAILING_GRAND_SUMMARY);
_part.height = 111 + (25*_max);
forms[_form].controller.recreateUI();
Mike
Hi Mike,
If you look at my code snippet then you see that I am not using the forms object at all.
var _oForm = solutionModel.getForm(myFormName),
_oPart = _oForm.getPart(JSPart.TRAILING_GRAND_SUMMARY);
The getPart() function is not a function that exists on a form object but on the JSForm object. Those are 2 different things.
The form object is the form instance that is created in memory from the form blueprint. The form blueprint object is the JSForm object (see solutionModel node in the Solution Explorer view).
So in your code you are mixing solutionModel code with runtime code. That won’t work.
So your code should look like this:
var _max = 3;
var _formName = "xy";
var _formBlueprint = solutionModel.getForm(_formName);
var _partBlueprint = _formBlueprint.getPart(JSPart.TRAILING_GRAND_SUMMARY);
_partBlueprint.height = 111 + (25*_max);
forms[_formName].controller.recreateUI();
Hope this explains things better.
Ok, I see!
Now it works. Thanks!
MIKE